Skip to content

Commit

Permalink
Bugfix: search backwards with operator (#5041)
Browse files Browse the repository at this point in the history
This PR removes an unnecessary restriction that prevents search backwards ("?") with an operator.

Fixes #4506
Fixes #4647
  • Loading branch information
sql-koala committed Jul 17, 2020
1 parent 95371fb commit 67c5322
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/actions/commands/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,13 +1204,6 @@ export class CommandSearchBackwards extends BaseCommand {
isMotion = true;
isJump = true;

public doesActionApply(vimState: VimState, keysPressed: string[]): boolean {
// Prevent collision with `g?` (rot13 operator)
return (
super.doesActionApply(vimState, keysPressed) && vimState.recordedState.operator === undefined
);
}

public async exec(position: Position, vimState: VimState): Promise<VimState> {
globalState.searchState = new SearchState(
SearchDirection.Backward,
Expand Down
16 changes: 16 additions & 0 deletions test/mode/modeNormal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,22 @@ suite('Mode Normal', () => {
endMode: Mode.Normal,
});

newTest({
title: 'Can delete with search forward',
start: ['foo |junk junk bar'],
keysPressed: 'd/bar\n',
end: ['foo |bar'],
endMode: Mode.Normal,
});

newTest({
title: 'Can delete with search backward',
start: ['foo junk garbage trash |bar'],
keysPressed: 'd?junk\n',
end: ['foo |bar'],
endMode: Mode.Normal,
});

newTest({
title: 'Can do C',
start: ['export const options = {', '|', '};'],
Expand Down

0 comments on commit 67c5322

Please sign in to comment.