Skip to content

Commit

Permalink
Add isJump to sneak actions (VSCodeVim#4697)
Browse files Browse the repository at this point in the history
When you do a search with vim-sneak, VSCodeVim doesn't save your
position and you can't go back to where you were before using .

This PR adds isJump to both sneak movements to fix that.

Fixes VSCodeVim#4696.
  • Loading branch information
luisherranz authored and berknam committed May 5, 2020
1 parent 6dd7823 commit 63047ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/actions/plugins/sneak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export class SneakForward extends BaseMovement {
['s', '<character>', '<character>'],
['z', '<character>', '<character>'],
];
isJump = true;

public couldActionApply(vimState: VimState, keysPressed: string[]): boolean {
const startingLetter = vimState.recordedState.operator === undefined ? 's' : 'z';
Expand Down Expand Up @@ -76,6 +77,7 @@ export class SneakBackward extends BaseMovement {
['S', '<character>', '<character>'],
['Z', '<character>', '<character>'],
];
isJump = true;

public couldActionApply(vimState: VimState, keysPressed: string[]): boolean {
const startingLetter = vimState.recordedState.operator === undefined ? 'S' : 'Z';
Expand Down
28 changes: 28 additions & 0 deletions test/plugins/sneak.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,34 @@ suite('sneak plugin', () => {
keysPressed: '3sa\n',
end: ['abc', 'aac', '|abc'],
});

newTest({
title: 'Can go back using <C-o> once when going forward',
start: ['|abc abc'],
keysPressed: 'sab<C-o>',
end: ['|abc abc'],
});

newTest({
title: 'Can go back using <C-o> once when going backward',
start: ['abc |abc'],
keysPressed: 'Sab<C-o>',
end: ['abc |abc'],
});

newTest({
title: 'Can go back using <C-o> when repeating forward movement',
start: ['|abc abc abc'],
keysPressed: 'sab;<C-o>',
end: ['|abc abc abc'],
});

newTest({
title: 'Can go back using <C-o> when repeating backward movement',
start: ['abc abc |abc'],
keysPressed: 'sab;<C-o>',
end: ['abc abc |abc'],
});
});

suite('sneakReplacesF', () => {
Expand Down

0 comments on commit 63047ce

Please sign in to comment.