jlelong / vscode-latex-basics

LaTeX grammars for Visual Studio Code
MIT License
19 stars 10 forks source link

Nested \( \) Highlight #67

Closed sleepymalc closed 11 months ago

sleepymalc commented 1 year ago

A clear and concise description of what the bug is.

A minimal example to reproduce the issue

\hyperref[\(\)]{\(\)}

jlelong commented 1 year ago

Actually, I do not think the new rendering of hyperref is a bug. Let's have a closer look.

First, disabling editor.bracketPairColorization.enabled removes what you call the weird colouring

Capture d’écran 2023-09-17 à 17 31 11

Second, why did not we have this weird colouring before version 1.5.3 of the LaTeX grammar? This is because \(...\) inside the first bracket pair was considered as delimiters of a math block before #59. This was actually wrong. It seems to me that the new grammar is better and uses more relevant scopes.

Btw, \hyperref expects a label as its optional argument. Isn't it a bit weird to find \( inside a label? I would even have thought this these are not accepted as part of a label.

sleepymalc commented 1 year ago

I understand the expected behavior for the first optional argument, i.e., \hyperlink[\(\)]{some text...}, is probably not correct and should not be used in the first place. However, a more concerning problem is for the second argument, i.e., \hyperlink[some label]{\(\)}: this is what I use on a daily basis. However, now it's not rendered in the usual way. I think a potential reason is the following:

image

As you can see, the scope inside \(\) is not even math.

This causes me other problems when using other extensions (which is irrelevant to this one, though).

I'm not sure whether this is a VSCode bug or something else.

jlelong commented 1 year ago

You are right the second argument in \hyperlink[some label]{some text} is not matched against the LaTeX syntax, hence math is not highlighted. I will investigate if it can be fixed.