Skip to content

Commit a38a19c

Browse files
committed
fix(queries:ecma): proper numeric values
1 parent 0805bc8 commit a38a19c

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

runtime/queries/ecma/highlights.scm

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,22 @@
241241
(escape_sequence) @constant.character.escape
242242

243243
(regex) @string.regexp
244-
(number) @constant.numeric.integer
244+
245+
; future-proof fall-back, and `TypedArray` values (looks like float, but is int)
246+
(number) @constant.numeric
247+
; https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#prod-NumericLiteral
248+
((number) @constant.numeric.float
249+
(#match? @constant.numeric.float
250+
; `1.` isn't considered float,
251+
; for the same reason as `1e0`,
252+
; however `1.0` is float, which feels inconsistent
253+
"([.]|([eE]-)).*[^n]$"
254+
))
255+
((number) @constant.numeric.integer
256+
(#match? @constant.numeric.integer
257+
"^[^+.][^.\-]*n$"
258+
))
259+
245260

246261
; Special identifiers
247262
;--------------------

0 commit comments

Comments
 (0)