Add support for parenthesis in "when" conditions
See original GitHub issue- VSCode Version: 1.42.0
- OS Version: Ubuntu 18.04.3
The when
expression that contains parentheses which we set for a keybinding defined in the contribution point of our extension results into a corrupted (invalidly transformed expression in user’s keybinding settings), e.g. the following declaration:
{
"command": "extension.helloWorld",
"key": "enter",
"when": "editorLangId == rust && !suggestWidgetVisible && (!vim.active || vim.mode == 'Insert')"
}
produces the following invalid when expression:
Steps to Reproduce:
- Go to the following repo with the reproduction
- Follow the steps in README.md
Does this issue occur when all extensions are disabled?: Yes
Issue Analytics
- State:
- Created 4 years ago
- Reactions:66
- Comments:14 (6 by maintainers)
Top Results From Across the Web
Add parenthesis support for if: conditions - GitLab.org
Allow to create a complex expressions and conditions with () in expressions: supports only:variables: supports rules:if: Example:.
Read more >When should you use parentheses inside an if statement's ...
You should generally use the parenthesis when you have to, and that would be when issues with operator presedence occur. – adeneo. Mar...
Read more >SQL: Using Parentheses with And / OR condition is necessary ...
My answer was YES, I use parenthesis to bind components of where clauses, i.e., If the query has multiple and or condition, ...
Read more >Should I fully parenthesize expressions or rely on precedence ...
Good developers strive to write code that is clear and correct. Parentheses in conditionals, even if they are not strictly required, help with...
Read more >AND and OR operators and parenthesis in queries
Use parentheses to group the OR statements in queries ... If you have an AND statement and a number of logically related OR...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
at the very least the Keyboard Shortcuts UI should reject inputs that contain parentheses (if they’re not supported currently) instead of garbling the user input resulting in non-functioning expressions and no undo.
I’ve created a draft cl / POC for how parentheses could be handled in a way that is unlikely to cause issue with existing parentheses in values and regex logic.
Still needs work, in particular regarding any conflicts with existing when clauses using brackets in regex, but it might be useful to open a discussion