Skip to content

Commit

Permalink
Use EnsureNL for go lexer
Browse files Browse the repository at this point in the history
To allow proper detection of single line comments when there is no \n

Fixes #380
  • Loading branch information
mrsdizzie authored and alecthomas committed Jul 15, 2020
1 parent e62d93f commit 4da591c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions lexers/g/go.go
Expand Up @@ -15,6 +15,7 @@ var Go = internal.Register(MustNewLexer(
Aliases: []string{"go", "golang"},
Filenames: []string{"*.go"},
MimeTypes: []string{"text/x-gosrc"},
EnsureNL: true,
},
Rules{
"root": {
Expand Down
2 changes: 1 addition & 1 deletion lexers/testdata/go.actual
Expand Up @@ -12,4 +12,4 @@ func hello(a int) {
return func() int {
return i
}
}
} // One last thing
4 changes: 3 additions & 1 deletion lexers/testdata/go.expected
Expand Up @@ -58,5 +58,7 @@
{"type":"Text","value":"\n "},
{"type":"Punctuation","value":"}"},
{"type":"Text","value":"\n"},
{"type":"Punctuation","value":"}"}
{"type":"Punctuation","value":"}"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// One last thing\n"}
]

0 comments on commit 4da591c

Please sign in to comment.