This extension automatically swaps the logic in a ternary expression for you. It will preserve formatting/whitespace, and a semicolon at the end, if included.
Supports nested ternaries.
: are ignored in strings.
/* */ comments are ignored. It will show an error if the ternary won't resolve (unbalanced if/then, unterminated string).
- Highlight ternary (nothing after the ternary except a
; or formatting)
- Hit ⇧⌥s (
shift + alt + s)
- Comments are grouped with the condition that precedes them, so they will not switch with the true/false cases.
- Testing that the error message is shown is not done, pending finding a way to mock some VS Code internals properly.
- Add support for Typscript
/* */ comments (fix single quotes in comments breaking parse)
Add keyboard shortcut