Vim icon indicating copy to clipboard operation
Vim copied to clipboard

[Draft] Improve % motion by using vscode editor.jumpToBracket

Open tim-tim707 opened this issue 11 months ago • 1 comments

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 ?

tim-tim707 avatar Nov 27 '24 16:11 tim-tim707