From 06d09756127a1410df69361a75a0ba534a827144 Mon Sep 17 00:00:00 2001 From: Dan Backes Date: Sun, 10 Apr 2016 17:17:27 -0500 Subject: [PATCH] Fixes Incorrect Cursor Position after Transition into Normal Mode - By having `redraw` enforce cursor position, we were double moving becase both `redraw` (via `Motion.changedMode`) and `handleActivationKey` were moving the cursor left. This makes it so `redraw` is not responsible for enforcing the cursor position. Instead, position enforcement is handled only when the cursor may have been moved externally (ie via the mouse). --- src/motion/motion.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/motion/motion.ts b/src/motion/motion.ts index 68446656f53..48e465dbcab 100644 --- a/src/motion/motion.ts +++ b/src/motion/motion.ts @@ -60,7 +60,13 @@ export class Motion implements vscode.Disposable { let line = selection.active.line; let char = selection.active.character; - this.position = new Position(line, char, null); + var newPosition = new Position(line, char, this._position.positionOptions); + + if (char > newPosition.getLineEnd().character) { + newPosition = new Position(newPosition.line, newPosition.getLineEnd().character, null); + } + + this.position = newPosition; this._desiredColumn = this.position.character; this.changeMode(this._motionMode); } @@ -103,11 +109,6 @@ export class Motion implements vscode.Disposable { // Valid Positions for Caret: [0, eol) this._position.positionOptions = PositionOptions.CharacterWiseExclusive; - if (this.position.character > this._position.getLineEnd().character) { - this._position = this._position.getLineEnd(); - this._desiredColumn = this._position.character; - } - this.highlightBlock(this.position); break;