From e73d62d944dbab45cc47c6636e37f6faefa682b2 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Thu, 11 Jun 2026 18:47:37 +0200 Subject: [PATCH] [JavaScript] Remove possibly stray branch failure This commit removes `ts-function-type-arguments` branch point failure from `ts-type-expression-end` as this context is also used in non-function-call expressions. Implementing failure outside of related branch points may have unpredictable side effects. Instead add a negative lookahead to prevent `||` or `&&` being consumed as sequence of type operators. Possible branch point failure is to be handled by "calling" context after popping `ts-type-expression-end`. Added tests should illustrate it not affecting syntax highlighting behavior of generic function calls. --- JavaScript/TypeScript.sublime-syntax | 6 ++---- JavaScript/tests/syntax_test_typescript.ts | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 95c49e80c0..81919451f9 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -847,12 +847,10 @@ contexts: - include: immediately-pop ts-type-expression-end: - - match: (?=\|\||&&) - fail: ts-function-type-arguments - - match: \& + - match: \&(?!\&) scope: keyword.operator.type.intersection.js push: [ts-type-expression-end-no-line-terminator, ts-type-expression-begin] - - match: \| + - match: \|(?!\|) scope: keyword.operator.type.union.js push: [ts-type-expression-end-no-line-terminator, ts-type-expression-begin] - match: is{{identifier_break}} diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index aa1c815536..14e8916b6e 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -391,6 +391,26 @@ import foo; declare(); // ^^^^^^^ meta.function-call variable.function + declare(); +// ^^^ meta.generic +// ^ punctuation.definition.generic.begin +// ^ support.class +// ^ punctuation.definition.generic.end + + declare(); +// ^^^^^^^^^ meta.generic.js +// ^ punctuation.definition.generic.begin.js +// ^^ support.class.js +// ^ keyword.operator.type.intersection.js +// ^^ support.class.js +// ^ punctuation.definition.generic.end.js + + declare(); +// ^^^^^^^^^^ - meta.generic + + declare>(); +// ^^^^^^^^^^^^^^^^^^^ - meta.generic + declare con; // ^^^^^^^ storage.modifier