From efbcac2188bda5eb23550997c191065bc5d3f283 Mon Sep 17 00:00:00 2001 From: Horace He Date: Sat, 20 May 2017 19:06:00 -0400 Subject: [PATCH] fixed a dumb bug --- src/actions/motion.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/actions/motion.ts b/src/actions/motion.ts index e14f1ddea..61bea6931 100644 --- a/src/actions/motion.ts +++ b/src/actions/motion.ts @@ -252,18 +252,20 @@ class MoveDownFoldFix extends MoveByScreenLineMaintainDesiredColumn { } let t: Position; let count = 0; + const prevDesiredColumn = vimState.desiredColumn; do { - t = (await new MoveDownByScreenLineMaintainDesiredColumn().execAction(position, vimState)); - count = 1; + t = (await new MoveDownByScreenLine().execAction(position, vimState)); + count += 1; } while (t.line === position.line); - if (t.line > position.line) { + if (t.line > position.line + 1) { return t; } while (count > 0) { - await new MoveUpByScreenLine().execAction(position, vimState); + t = await new MoveUpByScreenLine().execAction(position, vimState); count--; } - return await super.execAction(position, vimState); + vimState.desiredColumn = prevDesiredColumn; + return await position.getDown(vimState.desiredColumn); } } @@ -327,20 +329,23 @@ class MoveUpFoldFix extends MoveByScreenLineMaintainDesiredColumn { return position; } let t: Position; - + const prevDesiredColumn = vimState.desiredColumn; let count = 0; + do { t = (await new MoveUpByScreenLineMaintainDesiredColumn().execAction(position, vimState)); - count = 1; + count += 1; } while (t.line === position.line); - if (t.line < position.line) { + vimState.desiredColumn = prevDesiredColumn; + if (t.line < position.line - 1) { return t; } while (count > 0) { - await new MoveDownByScreenLine().execAction(position, vimState); + t = await new MoveDownByScreenLine().execAction(position, vimState); count--; } - return await super.execAction(position, vimState); + vimState.desiredColumn = prevDesiredColumn; + return await position.getUp(vimState.desiredColumn); } }