From 55c01b2a843aa5599935cb10190d6b6c7e1d6b07 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 13 Jun 2017 19:41:26 -0700 Subject: [PATCH 1/4] fixes #1817 yiw cursor position --- src/actions/operator.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/actions/operator.ts b/src/actions/operator.ts index e2fe189b557..69725c2ba42 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -234,8 +234,6 @@ export class YankOperator extends BaseOperator { vimState.cursorStartPosition = start; if (originalMode === ModeName.Normal) { - vimState.allCursors = vimState.cursorPositionJustBeforeAnythingHappened.map(x => new Range(x, x)); - } else { vimState.cursorPosition = start; } From f7045904c4aed2cdcd3508fbf8a50b42b67c1503 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 13 Jun 2017 19:46:14 -0700 Subject: [PATCH 2/4] Add test for yiw cursor position --- test/mode/modeNormal.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts index 43ea76bacca..c5faa5802ef 100644 --- a/test/mode/modeNormal.test.ts +++ b/test/mode/modeNormal.test.ts @@ -259,6 +259,14 @@ suite("Mode Normal", () => { endMode: ModeName.Insert }); + newTest({ + title: "Can handle 'yiw' with correct cursor ending position", + start: ['tes|t'], + keysPressed: 'yiwp', + end: ['ttes|test'], + endMode: ModeName.Normal + }); + newTest({ title: "Can handle 'ciw'", start: ['text text tex|t'], From 8d42f3fbd94e4273d35c7ad35bdce6e3b853a285 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 13 Jun 2017 21:53:44 -0700 Subject: [PATCH 3/4] Change yank cursor position when a movement was ran --- src/actions/operator.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/actions/operator.ts b/src/actions/operator.ts index 69725c2ba42..a0006875169 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -233,7 +233,10 @@ export class YankOperator extends BaseOperator { vimState.currentMode = ModeName.Normal; vimState.cursorStartPosition = start; - if (originalMode === ModeName.Normal) { + // Only change cursor position if we ran a movement + if (originalMode === ModeName.Normal && !vimState.recordedState.hasRunAMovement) { + vimState.allCursors = vimState.cursorPositionJustBeforeAnythingHappened.map(x => new Range(x, x)); + } else { vimState.cursorPosition = start; } From 9bd002393b3403b8bb5798026e873232c8576a68 Mon Sep 17 00:00:00 2001 From: xconverge Date: Tue, 13 Jun 2017 22:09:03 -0700 Subject: [PATCH 4/4] Only move cursor for yank with a specific type of text object motion --- src/actions/operator.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/actions/operator.ts b/src/actions/operator.ts index a0006875169..b81f877445a 100644 --- a/src/actions/operator.ts +++ b/src/actions/operator.ts @@ -6,6 +6,7 @@ import { Range } from './../common/motion/range'; import { ModeName } from './../mode/mode'; import { TextEditor } from './../textEditor'; import { Configuration } from './../configuration/configuration'; +import { TextObjectMovement } from './textobject'; import { BaseAction, RegisterAction, compareKeypressSequence } from './base'; @@ -233,8 +234,15 @@ export class YankOperator extends BaseOperator { vimState.currentMode = ModeName.Normal; vimState.cursorStartPosition = start; - // Only change cursor position if we ran a movement - if (originalMode === ModeName.Normal && !vimState.recordedState.hasRunAMovement) { + // Only change cursor position if we ran a text object movement + let moveCursor = false; + if (vimState.recordedState.actionsRun.length > 1) { + if (vimState.recordedState.actionsRun[1] instanceof TextObjectMovement) { + moveCursor = true; + } + } + + if (originalMode === ModeName.Normal && !moveCursor) { vimState.allCursors = vimState.cursorPositionJustBeforeAnythingHappened.map(x => new Range(x, x)); } else { vimState.cursorPosition = start;