Skip to content

Commit 6e3d229

Browse files
committed
Grammar: Fix var x = init(...) highlighting
This fixes change introduced in a8328ab that was adding type highlighting in `var x Type`. However the rule (.*)\s*(?:=|$) was greedy consuming everything until `=` or `$` (end of line). As a consequence it was effectively matching everything till end of line, consuming also `=` and everything that follows, resulting incorrect highlight, for eg.: var addr = flag.String("addr", ":8080", "TCP address to listen to") Now replacing RE to use lazy (non-greedy) (.*?)\s*(?:=|$) rule.
1 parent 7cb7593 commit 6e3d229

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Syntaxes/Go.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@
469469
<key>comment</key>
470470
<string>This matches the 'var x' style of variable declaration.</string>
471471
<key>match</key>
472-
<string>^\s*(var)\s+((?:[[:alpha:]_]\w*)(?:,\s+[[:alpha:]_]\w*)*)\s*(.*)\s*(?:=|$)</string>
472+
<string>^\s*(var)\s+((?:[[:alpha:]_]\w*)(?:,\s+[[:alpha:]_]\w*)*)\s*(.*?)\s*(?:=|$)</string>
473473
<key>name</key>
474474
<string>meta.initialization.explicit.go</string>
475475
</dict>

0 commit comments

Comments
 (0)