From 63047cec0030a620b7611199240c67883b25ae68 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Fri, 24 Apr 2020 06:11:15 +0200 Subject: [PATCH] Add isJump to sneak actions (#4697) 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 #4696. --- src/actions/plugins/sneak.ts | 2 ++ test/plugins/sneak.test.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/actions/plugins/sneak.ts b/src/actions/plugins/sneak.ts index e6347273ba7e..b7d2f19a81bf 100644 --- a/src/actions/plugins/sneak.ts +++ b/src/actions/plugins/sneak.ts @@ -11,6 +11,7 @@ export class SneakForward extends BaseMovement { ['s', '', ''], ['z', '', ''], ]; + isJump = true; public couldActionApply(vimState: VimState, keysPressed: string[]): boolean { const startingLetter = vimState.recordedState.operator === undefined ? 's' : 'z'; @@ -76,6 +77,7 @@ export class SneakBackward extends BaseMovement { ['S', '', ''], ['Z', '', ''], ]; + isJump = true; public couldActionApply(vimState: VimState, keysPressed: string[]): boolean { const startingLetter = vimState.recordedState.operator === undefined ? 'S' : 'Z'; diff --git a/test/plugins/sneak.test.ts b/test/plugins/sneak.test.ts index f54f60c707e8..0126537ccec7 100644 --- a/test/plugins/sneak.test.ts +++ b/test/plugins/sneak.test.ts @@ -131,6 +131,34 @@ suite('sneak plugin', () => { keysPressed: '3sa\n', end: ['abc', 'aac', '|abc'], }); + + newTest({ + title: 'Can go back using once when going forward', + start: ['|abc abc'], + keysPressed: 'sab', + end: ['|abc abc'], + }); + + newTest({ + title: 'Can go back using once when going backward', + start: ['abc |abc'], + keysPressed: 'Sab', + end: ['abc |abc'], + }); + + newTest({ + title: 'Can go back using when repeating forward movement', + start: ['|abc abc abc'], + keysPressed: 'sab;', + end: ['|abc abc abc'], + }); + + newTest({ + title: 'Can go back using when repeating backward movement', + start: ['abc abc |abc'], + keysPressed: 'sab;', + end: ['abc abc |abc'], + }); }); suite('sneakReplacesF', () => {