From 2bb96ae13399d9b90b6f16921b597c75b39ff683 Mon Sep 17 00:00:00 2001 From: Thomas Smith Date: Sat, 23 Sep 2023 10:58:42 -0400 Subject: [PATCH] [TypeScript] Better highlighting while typing declarations --- JavaScript/TypeScript.sublime-syntax | 13 +++++++++---- JavaScript/tests/syntax_test_typescript.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/JavaScript/TypeScript.sublime-syntax b/JavaScript/TypeScript.sublime-syntax index 0767815b3e..3734e5e0dc 100644 --- a/JavaScript/TypeScript.sublime-syntax +++ b/JavaScript/TypeScript.sublime-syntax @@ -334,7 +334,7 @@ contexts: - include: immediately-pop ts-interface-name: - - match: '{{identifier_name}}' + - match: '{{non_reserved_identifier}}' scope: entity.name.interface.js pop: 1 - include: else-pop @@ -348,6 +348,7 @@ contexts: scope: punctuation.section.block.end.js pop: 1 - include: ts-type-members + - include: else-pop ts-type-members: - match: '[,;]' @@ -456,7 +457,7 @@ contexts: - include: immediately-pop ts-type-alias-name: - - match: '{{identifier_name}}' + - match: '{{non_reserved_identifier}}' scope: entity.name.type.js pop: 1 - include: else-pop @@ -475,7 +476,7 @@ contexts: scope: keyword.declaration.js set: - ts-namespace-meta - - block + - ts-namespace-body - ts-namespace-name-end - ts-namespace-name @@ -484,6 +485,10 @@ contexts: - meta_scope: meta.namespace.js - include: immediately-pop + ts-namespace-body: + - include: block + - include: else-pop + ts-namespace-name-end: - match: \. scope: punctuation.accessor.dot.js @@ -491,7 +496,7 @@ contexts: - include: else-pop ts-namespace-name: - - match: '{{identifier_name}}' + - match: '{{non_reserved_identifier}}' scope: entity.name.namespace.js pop: 1 - include: else-pop diff --git a/JavaScript/tests/syntax_test_typescript.ts b/JavaScript/tests/syntax_test_typescript.ts index 3b380ddf9e..58dea7a800 100644 --- a/JavaScript/tests/syntax_test_typescript.ts +++ b/JavaScript/tests/syntax_test_typescript.ts @@ -553,6 +553,19 @@ import foo; // ^^^ entity.name.namespace // ^^ meta.block punctuation.section.block +// Don't break highlighting while typing +interface +class Foo {} +// <- meta.class keyword.declaration.class + +type +class Foo {} +// <- meta.class keyword.declaration.class + +namespace +class Foo {} +// <- meta.class keyword.declaration.class + /* Annotations */ var x: any = 42;