-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Parenthesis and brace matching within RegExps #148612
Comments
Looks like duplicate of #134560 |
I need this too. I noticed that braces are highlighted inside strings in .html files, like in this one: And if they could have that, I don't see a reason why Regex parenthesis, a brace or a bracket cannot have the same. I think this is not a duplicate of the mentioned issue. @pygy is asking for a highlight of the matching braces. The other issue is asking for colorization of braces. |
@Z-E-D matching or colorizing brackets still requires you to get proper bracket pairs first. See #134560 (comment) and #134560 (comment). |
The numerous web sites with online regexp testers prove that getting the proper bracket pairs is not an issue. Just tried By the way, the colorization of Regex elements is already possible with the proper themes. Just take a look at my screenshot in the #146260 issue. However, such colorization is not what many expect, since it doesn't have different colors for nested braces, i.e. all braces have the same color even if they are nested. Personally, I don't have a problem with that. |
Where did I said "it's impossible" or issue that is hard to solve? Moreover first linked comment provides an option for solution, it's just not something that is available in VS Code and looks like not planned at this moment (based on comments and label). I just pointed that this requires similar effort. You are right that changing colors based on nesting is more involved that just match braces, however if you have proper pairs then matching can be done and (nested) pairs highlight as next steps as well. TM Grammars are used to highlight RegExps, but it doesn't look like they are used to match brackets. Would be cool if they were used for RegExps. |
I see that tokenizing RegExps is an issue, I'm actually working on a RegExp tokenizer for my own purposes. Hopefully it will be useful here too. |
@hediet JS/TS and looks like Python, probably other as well, but haven't checked |
Let me reopen this to track this idea. I'm curious myself if it would work, but I don't have the time to do it at the moment. |
Couldn't RegExps be treated like an embedded language? Edit: note that, within the RegExp sub-language, character classes themselves must be treated as an embedded language. |
the problem isn't so much of detecting braces and matching them as you can see in my vscode TextMate extension |
Modifying regular expressions is a pain, and a part of that pain comes from the fact that editors don't help you with the task, they treat RegExps as if they were strings.
It would be nice, when the cursor is on a parenthesis, a brace or a bracket, to have the editor highlight the one that matches, like vscode does outside RegExps.
The text was updated successfully, but these errors were encountered: