Skip to content

Commit d95b0ea

Browse files
committed
Avoid matching constants without majuscules
1 parent f4ec66d commit d95b0ea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

grammars/javascript.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@
11681168
}
11691169
{
11701170
'match': '''(?x)
1171-
((?<!\\.|[\\w$])\\$*\\b(?:[A-Z_$][A-Z0-9_$]*)\\b\\$*)(?!\\s*:)
1171+
((?<!\\.|[\\w$])(?![_\\$]+[^A-Z0-9_$])\\$*\\b(?:[A-Z_$][A-Z0-9_$]*)\\b\\$*)(?!\\s*:)
11721172
|
11731173
(?<=\\?)(?:\\s*)([A-Z_$][A-Z0-9_$]*)(?=\\s*:)
11741174
'''

spec/javascript-spec.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ describe "Javascript grammar", ->
468468
{tokens} = grammar.tokenizeLine(constant)
469469
expect(tokens[0]).toEqual value: constant, scopes: ['source.js', 'constant.other.js']
470470

471+
it "doesn't tokenise constants without alphabetic characters", ->
472+
for name in ['$_', '$', '_', '$_$_$_$___$___$____$']
473+
{tokens} = grammar.tokenizeLine(name)
474+
expect(tokens[0]).toEqual value: name, scopes: ['source.js']
475+
471476
it "tokenizes variables declared using `const` as constants", ->
472477
{tokens} = grammar.tokenizeLine('const myCoolVar = 42;')
473478
expect(tokens[0]).toEqual value: 'const', scopes: ['source.js', 'storage.modifier.js']

0 commit comments

Comments
 (0)