Vim icon indicating copy to clipboard operation
Vim copied to clipboard

Add `gB` keybinding for finding the previous match

Open musjj opened this issue 1 year ago • 1 comments

Fix: https://github.com/VSCodeVim/Vim/issues/9000

What this PR does / why we need it:

gb is a nice binding, so the inverse of it would be useful.

You can bind editor.action.addSelectionToPreviousFindMatch in your config, but the nice thing about the built-in gb is that it aligns all the selection ends of the cursors.

Which issue(s) this PR fixes

fixes #9000

Special notes for your reviewer:

musjj avatar Apr 28 '24 20:04 musjj

I merged this PR and tested it locally, and found an issue: When the word are not in current view, It flashed the view to the selected word but jump back to the original one.

https://github.com/VSCodeVim/Vim/assets/55341525/cace293c-4a90-4e10-8b7d-fd780292e9c5

I discovered the problem through debugging

https://github.com/VSCodeVim/Vim/blob/3c33d00fdd37ba21d97a6a8c2daa7257d2722867/src/mode/modeHandler.ts#L1472-L1475

You need to add ActionPreviousFindMatch here as well

like this:

      const lastActionRun =
        this.vimState.recordedState.actionsRun[this.vimState.recordedState.actionsRun.length - 1];
      const isLastCursorTracked =
        lastActionRun instanceof ActionOverrideCmdD ||
        lastActionRun instanceof ActionPreviousFindMatch;

HenryTSZ avatar May 24 '24 02:05 HenryTSZ