summaryrefslogtreecommitdiff
path: root/state.go
diff options
context:
space:
mode:
authorAdam Scarr <adam@vektah.net>2017-08-13 21:20:41 +1000
committerAdam Scarr <adam@vektah.net>2017-08-13 21:20:41 +1000
commit139e7606f4ab68b469438956c378745f51f7b65b (patch)
tree2eaa9cb87e008ecaffefc01c5da933f1ea9852dd /state.go
parent1c37779bd46d988c9e7b4bdb846b9daa89856b7c (diff)
Update benchmarks
Diffstat (limited to 'state.go')
-rw-r--r--state.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/state.go b/state.go
index 1b7e9f2..5d35ac8 100644
--- a/state.go
+++ b/state.go
@@ -1,6 +1,7 @@
package goparsify
import (
+ "strconv"
"unicode"
"unicode/utf8"
)
@@ -72,11 +73,14 @@ func (s *State) Preview(x int) string {
if s.Pos >= len(s.Input) {
return ""
}
- if len(s.Input)-s.Pos >= x {
- return s.Input[s.Pos : s.Pos+x]
+
+ quoted := strconv.Quote(s.Get())
+ quoted = quoted[1 : len(quoted)-1]
+ if len(quoted) >= x {
+ return quoted[0:x]
}
- return s.Input[s.Pos:]
+ return quoted
}
// ErrorHere raises an error at the current position.