File tree Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 44 "fmt"
55 "strings"
66 "unicode/utf8"
7-
8- "golang.org/x/text/width"
97)
108
119type Error struct {
@@ -18,11 +16,6 @@ const (
1816 ind = "^"
1917)
2018
21- var (
22- wideDot = width .Widen .String (dot )
23- wideInd = width .Widen .String (ind )
24- )
25-
2619func (e * Error ) Error () string {
2720 return e .Message
2821}
@@ -46,17 +39,20 @@ func (e *Error) Format(source *Source) string {
4639 _ , sz := utf8 .DecodeRune (bytes )
4740 bytes = bytes [sz :]
4841 if sz > 1 {
49- indLine += wideDot
42+ goto noind
5043 } else {
5144 indLine += dot
5245 }
5346 }
5447 if _ , sz := utf8 .DecodeRune (bytes ); sz > 1 {
55- indLine += wideInd
48+ goto noind
5649 } else {
5750 indLine += ind
5851 }
59- result += srcLine + indLine
52+ srcLine += indLine
53+
54+ noind:
55+ result += srcLine
6056 }
6157 return result
6258}
Original file line number Diff line number Diff line change @@ -7,5 +7,4 @@ require (
77 github.com/rivo/tview v0.0.0-20200219210816-cd38d7432498
88 github.com/sanity-io/litter v1.2.0
99 github.com/stretchr/testify v1.5.1
10- golang.org/x/text v0.3.2
1110)
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRci
2323github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4 =
2424github.com/stretchr/testify v1.5.1 /go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA =
2525golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
26+ golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo =
2627golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 /go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs =
2728golang.org/x/text v0.3.0 /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
2829golang.org/x/text v0.3.2 /go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk =
Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ id "hello
152152literal not terminated (1:10)
153153 | id "hello
154154 | .........^
155+
156+ früh ♥︎
157+ unrecognized character: U+2665 '♥' (1:7)
158+ | früh ♥︎
155159`
156160
157161func TestLex_error (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments