Skip to content

Bracket pair colorizing fails in nested template strings #190564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nking07049925 opened this issue Aug 16, 2023 · 3 comments · Fixed by #245786 · May be fixed by #195557
Closed

Bracket pair colorizing fails in nested template strings #190564

nking07049925 opened this issue Aug 16, 2023 · 3 comments · Fixed by #245786 · May be fixed by #195557
Assignees
Labels
bracket-pair-colorization bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders
Milestone

Comments

@nking07049925
Copy link

Type: Bug

The following line of code has a template placeholder ${getWorld((5 - 1) + "123"[2])} two times. On the top level of the template string and inside another template string inside a placeholder.

    test = `Hello, ${getWorld((5 - 1) + "123"[2])} ${`${getWorld((5 - 1) + "123"[2])}`}`;

image

The one in the top level gets the bracket pair colorized and the one deeper doesn't.

VS Code version: Code 1.81.1 (6c3e3db, 2023-08-09T22:22:42.175Z)
OS version: Windows_NT x64 10.0.22621

@hediet hediet added bug Issue identified by VS Code Team member as probable bug bracket-pair-colorization labels Aug 16, 2023
@hediet hediet added this to the Backlog milestone Aug 16, 2023
@username-not-known
Copy link

username-not-known commented Aug 20, 2023

The BUG:
token metadata for nested brackets are not encoded with 'other' token type (StandardTokenType.Other).
Thus, the tokenizer assumes nested brackets as texts in the ast.
For sure: tokenization bug (vscode-textmate,oniguruma),
but the grammar causes this?
I haven't gathered the time & energy to proceed further with this.

@hediet
Copy link
Member

hediet commented Aug 21, 2023

I'm quite sure this is a (probably known) issue of the TypeScript/JavaScript grammar.

@RedCMD
Copy link
Contributor

RedCMD commented Apr 5, 2025

This is caused by tokenTypes inside package.json

"tokenTypes": {
          "meta.template.expression": "other",
          "meta.template.expression string": "string",
          "meta.template.expression comment": "comment"
}

"tokenTypes": {
"meta.template.expression": "other",
"meta.template.expression string": "string",
"meta.template.expression comment": "comment",


174db5e was added as a bad fix for

"meta.template.expression string": "string",
"meta.template.expression comment": "comment"

and #134662 was caused by bc0e917, as a bad fix for

"meta.template.expression": "other"

version 1.59.1 was working correctly
version 1.60.0 was broken with bc0e917
version 1.62.0 was broken with 174db5e

PR #245786

hediet pushed a commit to RedCMD/vscode that referenced this issue Apr 11, 2025
@vs-code-engineering vs-code-engineering bot added the unreleased Patch has not yet been released in VS Code Insiders label Apr 11, 2025
@hediet hediet modified the milestones: Backlog, April 2025 Apr 11, 2025
@vs-code-engineering vs-code-engineering bot added insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bracket-pair-colorization bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders
Projects
None yet
4 participants