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

Support coloring a subset of the matched brackets #170497

Closed
hediet opened this issue Jan 3, 2023 · 5 comments · Fixed by #172758
Closed

Support coloring a subset of the matched brackets #170497

hediet opened this issue Jan 3, 2023 · 5 comments · Fixed by #172758
Assignees
Labels
bracket-pair-colorization feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders plan-item VS Code - planned item for upcoming verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@hediet
Copy link
Member

hediet commented Jan 3, 2023

This issue changes the behavior when both brackets and colorizedBracketPairs are configured, for example through this configuration:

"[plaintext]": {
    "editor.language.brackets": [
      ["{", "}"],
      ["(", ")"],
      ["[", "]"]
    ],
    "editor.language.colorizedBracketPairs": [
      ["{", "}"],
      ["<", ">"]
    ]
  },

In this case, the four bracket pairs {}, (), [] and <> should be matched.
However, only the pairs {} and <> should get highlighted.

Code_-_OSS_R4wyxSgWhT

In particular, this restores the bracket matching behavior for plain text files before colorization was introduced.

Verification Steps

Configure editor.language.brackets and editor.language.colorizedBracketPairs and verify that the former just matches brackets and the latter colorizes them. Verify they can be configured independently.

@hediet hediet added the plan-item VS Code - planned item for upcoming label Jan 3, 2023
@hediet hediet added this to the January 2023 milestone Jan 3, 2023
@hediet hediet self-assigned this Jan 3, 2023
@hediet hediet added feature-request Request for new features or functionality bracket-pair-colorization labels Jan 3, 2023
@hediet hediet modified the milestones: January 2023, February 2023 Jan 26, 2023
hediet added a commit that referenced this issue Jan 30, 2023
hediet added a commit that referenced this issue Feb 1, 2023
* Fixes #170497

* Fixes bug and adds tests.
@VSCodeTriageBot VSCodeTriageBot added the unreleased Patch has not yet been released in VS Code Insiders label Feb 1, 2023
@VSCodeTriageBot VSCodeTriageBot 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 Feb 3, 2023
@RedCMD
Copy link
Contributor

RedCMD commented Feb 9, 2023

I wonder if there is any use to disable 'match' highlighting on brackets that are only listed in editor.language.colorizedBracketPairs, but not editor.language.brackets
for example, the angle brackets in the gif would be coloured but wont have the squares boxes around them

this would mean that if editor.bracketPairColorization.enabled is disabled, <> wouldn't be coloured or have match highlighting
and thus would be visually treated as normal text, but still retain internal nesting levels

@hediet
Copy link
Member Author

hediet commented Feb 9, 2023

I wonder if there is any use to disable 'match' highlighting on brackets that are only listed in

What would be your use-case?

@RedCMD
Copy link
Contributor

RedCMD commented Feb 12, 2023

I don't have any atm
was just an idea that possibly someone else might want/need

@hediet hediet added the verification-needed Verification of issue is requested label Feb 20, 2023
@jrieken jrieken added the verified Verification succeeded label Feb 21, 2023
@RedCMD
Copy link
Contributor

RedCMD commented Mar 3, 2023

Not sure if this is a bug or feature (I would incline towards feature)
if a bracket pair is listed under "brackets" but not "colorizedBracketPairs"
it can still be marked as invalid if it is not matching in a document

image
image
[ is marked as invalid, even tho it is not under "colorizedBracketPairs"

@hediet
Copy link
Member Author

hediet commented Mar 3, 2023

This was a compromise, as for unclosed/unopened brackets we don't really know if it is colorized or not, as that depends on the missing opening/closing bracket (only complete pairs are colorized and different pairs can share brackets).
However, I'm just considering a change that brackets that are not colorized in any pair don't get red when they are unopened/unclosed. This fixes https://stackoverflow.com/questions/75610880/why-are-some-left-and-right-angle-brackets-colored-red-in-vscode and others for now.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bracket-pair-colorization feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders plan-item VS Code - planned item for upcoming verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants