Skip to content

Conversation

@yshaojun
Copy link
Contributor

Fix #190564

In extensions/typescript-basics/syntaxes/TypeScript.tmLanguage.json, The selectors which start with "string" are "string.quoted", "string.regexp" and "string.template", in fact we should only treat "string.quoted" as string. Please check!

@hediet
Copy link
Member

hediet commented Oct 13, 2023

This also does not fix it, as it would highlight brackets in

const myStr = `(`;

@yshaojun
Copy link
Contributor Author

This also does not fix it, as it would highlight brackets in

const myStr = `(`;

Got it. Probably other selector expression can make it.

@yshaojun yshaojun closed this Oct 13, 2023
@yshaojun
Copy link
Contributor Author

@hediet I can't reproduce your case, I get the following result which bracket not highlight.

screenshot-20231014-230420

@yshaojun yshaojun reopened this Oct 14, 2023
@hediet
Copy link
Member

hediet commented Oct 16, 2023

Ah, this one only marks quoted strings as strings. Template strings are not marked as strings. I fear this causes other problems, e.g. for the bracket auto-closing.

@yshaojun
Copy link
Contributor Author

I see. I can't ensure other problems either as my poor understanding of the codebase.

@Marcelotsvaz
Copy link

The expression enclosed by ${ and } inside a template string is scoped with meta.embedded.line.js. That resets the token type to other (microsoft/vscode-textmate#54). An important difference from tokenTypes in package.json is that meta.embedded enables proper nesting. The token type is determined by the last meta.embedded or string scope.

So I think we can remove all these:

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

This leaves one problem. ${ and } don't have the meta.embedded.line.js scope, only meta.template.expression.js. We can target these symbols with punctuation.definition.template-expression, like that:

"punctuation.definition.template-expression": "other",

I'm not very familiar with JavaScript, I'm actually working on https://github.com/bmalehorn/vscode-fish, so I'm not totally sure this will work.

Here is how it looks like:
Screenshot 2023-10-18 22:20:18

@hediet hediet added this to the November 2023 milestone Oct 20, 2023
@hediet hediet modified the milestones: November 2023, December 2023 Nov 29, 2023
@hediet hediet modified the milestones: December / January 2024, February 2024 Jan 22, 2024
@hediet hediet modified the milestones: February 2024, March 2024 Feb 20, 2024
@hediet hediet modified the milestones: March 2024, April 2024 Mar 25, 2024
@hediet hediet modified the milestones: April 2024, May 2024 Apr 25, 2024
@hediet hediet modified the milestones: May 2024, June 2024 May 27, 2024
@hediet hediet modified the milestones: June 2024, July 2024 Jun 25, 2024
@hediet hediet modified the milestones: July 2024, On Deck Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bracket pair colorizing fails in nested template strings

3 participants