Vim
Vim copied to clipboard
[Draft] Improve % motion by using vscode editor.jumpToBracket
Using % motion on brackets doesn't work properly if there are unmatched brackets in comments
function test() {
// if {
return 1;
}
The % motion with editor.jumpToBracket was also discussed in (#651). The motion didn't work properly with multicursor before, and this PR doesn't address this particular issue.
I also remember an issue talking specifically about the unmatched bracket but I cannot find it.
This PR calls editor.jumpToBracket in the case of bracket matching without selection. I tried to make it work with selection, but the command doesn't move the cursor and clears the selection if it exists. Trying to call jumpToBracket twice in a row when there is a selection, and saving + trying to restore the selection afterward creates a conflict between vscode cursor and vim cursor where they are not at the same location.
I would like to make it work with selection in the future but I don't really understand how to fix this yet.
Maybe I should call the editor commands elsewhere than PairMatcher like in the '%' operator somehow ?