Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tim-tim707
Copy link

@tim-tim707 tim-tim707 commented Nov 27, 2024

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
Copy link
Author

Doesn't work properly with Visual Block. Selection is empty in this case, vscode cursor moves, but vim one doesn't

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant