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

Fix Math Brackets Highlight #1534

Closed
wants to merge 1 commit into from
Closed

Fix Math Brackets Highlight #1534

wants to merge 1 commit into from

Conversation

toooonyy
Copy link

close #1529, the code is from @chenr12

@jlelong
Copy link
Collaborator

jlelong commented Jul 24, 2019

From the discussion in #1430.

We already match ["{", "}"], ["[", "]"], ["(", ")"]. It is currently not possible to also match ["\left(", '\right)'], ["\left[", '\right]'] because of microsoft/vscode/issues/58619.
I suggest to declare "\left", "\right" as a pair.

Your patch is only good for people using Bracket Pair Colorizer 2, which has been reported to create some incompatibilities with LaTeX-Workshop. For other people, it is good to match \left and \right as a pair

Capture d’écran 2019-07-24 à 09 38 20

See the small boxes around \left and \right, they are rendered by vscode itself when editor.matchBrackets is set. This does not work with your patch. Because of this I do not think this is a good idea to merge your patch. Sorry.

@jlelong jlelong closed this Jul 24, 2019
This was referenced Aug 27, 2019
@WasabiFan
Copy link
Contributor

@jlelong Can you help me understand the scenario here?

I locally applied this patch onto recent master (7f4a778) and tried the example shown above. VSCode applies the box highlighting similar to how your screenshot shows it, however it includes the following parenthesis as well:

image

It seems to me like this works as expected. I would personally prefer this behavior, since the parenthesis after the \left or \right is semantically part of the same "brace pair".

Perhaps the behavior of vscode has changed since this was originally tested?

It's worth noting that this PR doesn't include < brackets, which would probably be good to include. Auto-closing braces' functionality is unchanged from its current behavior, as far as I can tell: it operates on the parenthesis alone unless you use the automatic \left( command suggestion.

For completeness, I tried enabling the Bracket Pair Colorizer 2 extension which was mentioned in some other threads; it now correctly highlights left/right pairs (because before the syntax definition would have suggested interleaved pairs of brackets) and no longer partially-colors commands which begin with \left or \right as a prefix, e.g. \leftarrow:

image

I tried out a few other "bracket"-based extensions (https://marketplace.visualstudio.com/items?itemName=chunsen.bracket-select, https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets) and they seem to work together with this extension as well.

All in all, I would appreciate this change being revisited. It's unfortunate VSCode doesn't seem to provide more intelligent handling of bracket pairs (e.g. allow a wildcard for the character following \left or \right); in the absence of that functionality, I think the change in this PR would improve the semantics that LaTeX Workshop reports to VSCode.

@jlelong
Copy link
Collaborator

jlelong commented Apr 1, 2020

@WasabiFan Thanks for digging up this PR! You are right, this PR works fine now! Probably due to some changes in VSCode. I am merging it!

jlelong added a commit that referenced this pull request Apr 1, 2020
This commit actually corresponds to PR #1534.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Math Brackets Highlight
3 participants