From ae985885b9f9dc7b8bcc8bfd55908aa171b83409 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 30 Sep 2024 10:40:22 +0200 Subject: [PATCH] Fix test error --- .../test-issue11_ts.json | 16 ++++++++-------- .../test-issue5431_ts.json | 12 ++++++------ .../test-issue5566_ts.json | 16 ++++++++-------- .../test-keywords_ts.json | 2 +- .../colorize-tree-sitter-results/test_ts.json | 10 +++++----- .../common/languages/highlights/typescript.scm | 10 +++------- .../browser/treeSitterTokenizationFeature.ts | 4 ++-- 7 files changed, 33 insertions(+), 37 deletions(-) diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue11_ts.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue11_ts.json index 60fc1bedb814d..6fb2651c7c5ac 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue11_ts.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue11_ts.json @@ -1989,7 +1989,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -2507,7 +2507,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -2801,16 +2801,16 @@ }, { "c": "t", - "t": "variable variable.other.constant", + "t": "variable", "r": { - "dark_plus": "variable.other.constant: #4FC1FF", - "light_plus": "variable.other.constant: #0070C1", + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", "hc_black": "variable: #9CDCFE", - "dark_modern": "variable.other.constant: #4FC1FF", - "hc_light": "variable.other.constant: #02715D", - "light_modern": "variable.other.constant: #0070C1" + "dark_modern": "variable: #9CDCFE", + "hc_light": "variable: #001080", + "light_modern": "variable: #001080" } }, { diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5431_ts.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5431_ts.json index d5508bf6b0a8e..2f99899f2a110 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5431_ts.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5431_ts.json @@ -155,16 +155,16 @@ }, { "c": "timeRange", - "t": "variable variable.other.constant", + "t": "variable", "r": { - "dark_plus": "variable.other.constant: #4FC1FF", - "light_plus": "variable.other.constant: #0070C1", + "dark_plus": "variable: #9CDCFE", + "light_plus": "variable: #001080", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", "hc_black": "variable: #9CDCFE", - "dark_modern": "variable.other.constant: #4FC1FF", - "hc_light": "variable.other.constant: #02715D", - "light_modern": "variable.other.constant: #0070C1" + "dark_modern": "variable: #9CDCFE", + "hc_light": "variable: #001080", + "light_modern": "variable: #001080" } }, { diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5566_ts.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5566_ts.json index edcd005f61cda..e055f0ae7caf5 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5566_ts.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-issue5566_ts.json @@ -85,16 +85,16 @@ }, { "c": "foo", - "t": "variable entity.name.function variable.other.constant", + "t": "variable entity.name.function", "r": { - "dark_plus": "variable.other.constant: #4FC1FF", - "light_plus": "variable.other.constant: #0070C1", + "dark_plus": "entity.name.function: #DCDCAA", + "light_plus": "entity.name.function: #795E26", "dark_vs": "default: #D4D4D4", "light_vs": "default: #000000", - "hc_black": "variable: #9CDCFE", - "dark_modern": "variable.other.constant: #4FC1FF", - "hc_light": "variable.other.constant: #02715D", - "light_modern": "variable.other.constant: #0070C1" + "hc_black": "entity.name.function: #DCDCAA", + "dark_modern": "entity.name.function: #DCDCAA", + "hc_light": "entity.name.function: #5E2CBC", + "light_modern": "entity.name.function: #795E26" } }, { @@ -169,7 +169,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-keywords_ts.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-keywords_ts.json index 88e4148cc63a9..f7b50872f0a80 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-keywords_ts.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test-keywords_ts.json @@ -85,7 +85,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ts.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ts.json index 75a2bd8790460..ca9e2cdd3a4b4 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ts.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ts.json @@ -323,7 +323,7 @@ }, { "c": "constructor", - "t": "variable meta.definition.method entity.name.function storage.type", + "t": "variable meta.definition.method storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -1457,7 +1457,7 @@ }, { "c": "constructor", - "t": "variable meta.definition.method entity.name.function storage.type", + "t": "variable meta.definition.method storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -2717,7 +2717,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -3319,7 +3319,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", @@ -3879,7 +3879,7 @@ }, { "c": "=>", - "t": "keyword.operator storage.type", + "t": "storage.type", "r": { "dark_plus": "storage.type: #569CD6", "light_plus": "storage.type: #0000FF", diff --git a/src/vs/editor/common/languages/highlights/typescript.scm b/src/vs/editor/common/languages/highlights/typescript.scm index d6f526386593b..5f6a6796883d1 100644 --- a/src/vs/editor/common/languages/highlights/typescript.scm +++ b/src/vs/editor/common/languages/highlights/typescript.scm @@ -61,9 +61,10 @@ (function_declaration name: (identifier) @entity.name.function) (method_definition - name: (property_identifier) @meta.definition.method @entity.name.function) + name: (property_identifier) @meta.definition.method @entity.name.function + (#not-eq? @entity.name.function "constructor")) (method_definition - name: (property_identifier) @storage.type + name: (property_identifier) @meta.definition.method @storage.type (#eq? @storage.type "constructor")) (method_signature name: (property_identifier) @meta.definition.method @entity.name.function) @@ -109,10 +110,6 @@ (predefined_type (["string" "boolean" "number" "any"])) @support.type.primitive (type_identifier) @entity.name.type -(("const") - (variable_declarator - name: (identifier) @variable.other.constant)) - ([ (identifier) (shorthand_property_identifier) @@ -192,7 +189,6 @@ "<<=" "==" "!=" - "=>" ">>" ">>=" ">>>" diff --git a/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts b/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts index 9bd32453f1e0b..0829476700c04 100644 --- a/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts +++ b/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts @@ -220,8 +220,8 @@ class TreeSitterTokenizationSupport extends Disposable implements ITreeSitterTok // Check that the current token doesn't just replace the last token if ((previousTokenStartOffset + currentTokenLength) === originalPreviousTokenEndOffset) { - // Current token and previous token span the exact same characters - endOffsetsAndScopes[tokenIndex - 1].scopes.push(capture.name); + // Current token and previous token span the exact same characters, replace the last scope + endOffsetsAndScopes[tokenIndex - 1].scopes[endOffsetsAndScopes[tokenIndex - 1].scopes.length - 1] = capture.name; } else { // The current token is within the previous token. Adjust the end of the previous token. endOffsetsAndScopes[tokenIndex - 1].endOffset = intermediateTokenOffset;