Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 9cf9a39

Browse files
committed
🐛 Tokenize '1.E3' as number
1 parent a6c28e8 commit 9cf9a39

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

grammars/javascript.cson

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,10 +859,10 @@
859859
'include': '#function_call'
860860
}
861861
{
862-
'include': '#object_variable'
862+
'include': '#numbers'
863863
}
864864
{
865-
'include': '#numbers'
865+
'include': '#object_variable'
866866
}
867867
{
868868
'include': '#properties'
@@ -937,12 +937,13 @@
937937
'match': '''(?x)
938938
(?<!\\$)(?:
939939
(?:\\b[0-9]+(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # 1.1E+3
940+
(?:\\b[0-9]+(\\.)[eE][+-]?[0-9]+\\b)| # 1.E+3
940941
(?:\\B(\\.)[0-9]+[eE][+-]?[0-9]+\\b)| # .1E+3
941942
(?:\\b[0-9]+[eE][+-]?[0-9]+\\b)| # 1E+3
942943
(?:\\b[0-9]+(\\.)[0-9]+\\b)| # 1.1
943944
(?:\\b[0-9]+(\\.)\\B)| # 1.
944945
(?:\\B(\\.)[0-9]+\\b)| # .1
945-
(?:\\b[0-9]+\\b) # 1
946+
(?:\\b[0-9]+\\b(?!\\.)) # 1
946947
)(?!\\$)
947948
'''
948949
'captures':
@@ -958,6 +959,8 @@
958959
'name': 'meta.delimiter.decimal.period.js'
959960
'5':
960961
'name': 'meta.delimiter.decimal.period.js'
962+
'6':
963+
'name': 'meta.delimiter.decimal.period.js'
961964
}
962965
]
963966
'operators':

spec/javascript-spec.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ describe "Javascript grammar", ->
228228
expect(tokens[0]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js']
229229
expect(tokens[1]).toEqual value: '1e-23', scopes: ['source.js', 'constant.numeric.decimal.js']
230230

231+
{tokens} = grammar.tokenizeLine('1.E3')
232+
expect(tokens[0]).toEqual value: '1', scopes: ['source.js', 'constant.numeric.decimal.js']
233+
expect(tokens[1]).toEqual value: '.', scopes: ['source.js', 'constant.numeric.decimal.js', 'meta.delimiter.decimal.period.js']
234+
expect(tokens[2]).toEqual value: 'E3', scopes: ['source.js', 'constant.numeric.decimal.js']
235+
231236
it "does not tokenize numbers that are part of a variable", ->
232237
{tokens} = grammar.tokenizeLine('hi$1')
233238
expect(tokens[0]).toEqual value: 'hi$1', scopes: ['source.js']

0 commit comments

Comments
 (0)