@@ -34,6 +34,8 @@ variables:
3434 propertyName : ({{anyNumber}}|({{identifier}})|{{nonIdentifierPropertyName}})
3535 constantVar : ({{constantIdentifier}})(?![_$[:alnum:]])
3636 endOfStatement : ' ;|^\s*abstract\b|^\s*async\b|^\s*class\b|^\s*const\b|^\s*declare\b|^\s*enum\b|^\s*export\b|^\s*function\b|^\s*import\b|^\s*interface\b|^\s*let\b|^\s*module\b|^\s*namespace\b|^\s*return\b|^\s*type\b|^\s*var\b'
37+ varExprStart : ' {{startOfDeclaration}}\b(var|let){{endOfIdentifier}}'
38+ constExprStart : ' {{startOfDeclaration}}\b(const(?!\s+enum\b)){{endOfIdentifier}}'
3739 nonPropertyLookBehind : ' [^\._$[:alnum:]]'
3840 lookBehindReturn : ' ^return|{{nonPropertyLookBehind}}return'
3941 lookBehindThrow : ' ^throw|{{nonPropertyLookBehind}}throw'
@@ -245,13 +247,15 @@ repository:
245247 patterns :
246248 # let/var
247249 - name : meta.var.expr.ts
248- begin : ' {{startOfDeclaration}}\b(var|let){{endOfIdentifier}}'
249- beginCaptures :
250- ' 1 ' : { name: keyword.control.export.ts }
251- ' 2 ' : { name: storage.modifier.ts }
252- ' 3 ' : { name: storage.type.ts }
253- end : ((?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<=\S)(?<!{{lookBehindLet}}|{{lookBehindVar}})(?=\s*$)))
250+ begin : (?={{varExprStart}})
251+ end : (?!{{varExprStart}})((?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<!{{lookBehindLet}}|{{lookBehindVar}})(?=\s*$)))
254252 patterns :
253+ - begin : ' {{varExprStart}}\s*'
254+ beginCaptures :
255+ ' 1 ' : { name: keyword.control.export.ts }
256+ ' 2 ' : { name: storage.modifier.ts }
257+ ' 3 ' : { name: storage.type.ts }
258+ end : (?=\S)
255259 - include : ' #destructuring-variable'
256260 - include : ' #var-single-variable'
257261 - include : ' #variable-initializer'
@@ -269,13 +273,19 @@ repository:
269273 - include : ' #punctuation-comma'
270274 # const
271275 - name : meta.var.expr.ts
272- begin : ' {{startOfDeclaration}}\b(const(?!\s+enum\b)){{endOfIdentifier}} '
276+ begin : (?={{constExprStart}})
273277 beginCaptures :
274278 ' 1 ' : { name: keyword.control.export.ts }
275279 ' 2 ' : { name: storage.modifier.ts }
276280 ' 3 ' : { name: storage.type.ts }
277- end : (( ?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<=\S) (?<!{{lookBehindConst}})(?=\s*$)))
281+ end : (?!{{constExprStart}})(( ?=;|}|(\s+(of|in)\s+)|^\s*$|{{endOfStatement}})|((?<!{{lookBehindConst}})(?=\s*$)))
278282 patterns :
283+ - begin : ' {{constExprStart}}\s*'
284+ beginCaptures :
285+ ' 1 ' : { name: keyword.control.export.ts }
286+ ' 2 ' : { name: storage.modifier.ts }
287+ ' 3 ' : { name: storage.type.ts }
288+ end : (?=\S)
279289 - include : ' #destructuring-const'
280290 - include : ' #var-single-const'
281291 - include : ' #variable-initializer'
0 commit comments