Skip to content
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

[Feature Request] Bracket Pair Colorization: Allow bracket pairs to share open tokens or close tokens #132209

Closed
roccomao opened this issue Sep 3, 2021 · 8 comments · Fixed by #132504
Assignees
Labels
bracket-pair-colorization bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities verification-needed Verification of issue is requested verified Verification succeeded

Comments

@roccomao
Copy link

roccomao commented Sep 3, 2021

The editor now supports native bracket pair colorization, but the languages where multiple bracket pairs share the same open token or close token are not correctly supported. This is a legacy issue from Bracket Pair Colorization (ref issue #301). DragWx has submitted a solution, ref PR #310, but the author(CoenraadS) has not reviewed and merged the code for a long time.

Actually, when setting "editor.bracketPairColorization.enabled": true to enable Bracket pair colorization, there will be some languages that can not be properly supported. So hopefully the developers can support this feature (#310).

It's also worth mentioning that the bracket matching of vscode works correctly, but the colorization is incorrect, as shown below:

example_01
example_02

PS: Here are some examples of languages that share open tokens or close tokens.

Verilog/SystemVerilog brackets examples:

[ case  , endcase ]
[ casex , endcase ]
[ casez , endcase ]

AL Language brackets examples:

[ case  , end; ]
[ begin , end; ]

LaTeX brackets examples:

[ \left( , \right) ]
[ \left( , \right. ]
[ \left. , \right) ]

PPS: @CoenraadS, In Bracket Pair Colorization, there are already many related issues: #301, #170, #416, #328, #332, #371, #349 (some are duplicates).

@hediet hediet added bracket-pair-colorization bug Issue identified by VS Code Team member as probable bug labels Sep 5, 2021
@hediet
Copy link
Member

hediet commented Sep 5, 2021

Thanks for reporting this!

I did not think of this case.
But I guess this can be easily fixed here:
A closing bracket token is assumed to close an opening bracket token if and only if they have equal category-numbers.
I guess in case of verilog, case, casex and casez should all have the same category (currently they have different ones).

If someone wants to contribute a PR, please ping me!

@hediet hediet added this to the September 2021 milestone Sep 5, 2021
@hediet hediet added the help wanted Issues identified as good community contribution opportunities label Sep 5, 2021
@DragWx
Copy link
Contributor

DragWx commented Sep 6, 2021

Hey @hediet, I've got a solution maybe 80% of the way there, once I add some tests and clean up, it'll be ready.

One thing though, the line tokenizer always seems to split tokens at backslashes \, and that interferes with LaTeX's \left\{ and \right\} brackets. The fast parser grabs these without any issues, but the moment the normal token-based parser is invoked, it's impossible to get these to match. I'm pretty certain this is a tokenizing issue and not a bracket-sharing issue, so I'm going to leave it alone so I can button everything else up.

The issues in Verilog and LaTeX which were related to bracket sharing, I think I've got those squared away, and I'll get a PR up tonight or tomorrow.

@hediet
Copy link
Member

hediet commented Sep 20, 2021

Implemented by #132504.

@hediet hediet added the verification-needed Verification of issue is requested label Sep 27, 2021
@rchiodo rchiodo self-assigned this Sep 29, 2021
@rchiodo rchiodo added the verified Verification succeeded label Sep 29, 2021
@rchiodo
Copy link
Contributor

rchiodo commented Sep 29, 2021

I'm not sure but I don't think this is working.

I have the following set:

    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": true,
    "workbench.colorCustomizations": {
        "[Default Light+]": {
            "editorBracketMatch.background": "#ff0000"
        }
    }

Which in a cpp file produces the following:

image

But I don't get similar results in a latex file:

image

Perhaps I need to install something else for it to work?

@rchiodo rchiodo added verification-steps-needed Steps to verify are needed for verification and removed verified Verification succeeded labels Sep 29, 2021
@rchiodo rchiodo removed their assignment Sep 29, 2021
@rchiodo
Copy link
Contributor

rchiodo commented Sep 29, 2021

It does seem to work for verilog cases though:

image

@hediet
Copy link
Member

hediet commented Sep 30, 2021

It only shows scope lines for multi-line bracket pairs. Your LaTeX example does not have those.

@rchiodo
Copy link
Contributor

rchiodo commented Sep 30, 2021

Your LaTeX example does not have those.

@hediet I thought these were multiline bracket pairs?

\begin{document}
...
\end{document}

@rzhao271
Copy link
Contributor

Marking as verified for now. I think for LaTeX, the idea is to identify \left\{ and \right\} as a bracket pair, whereas for something like \begin{document}, the bracket pair is just the { and }.

Example:

\begin{equation}
	\left\{2+2+3\right\}
\end{equation}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bracket-pair-colorization bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants