From 1c6db910f4953c98fac449462a54741edc10d9ec Mon Sep 17 00:00:00 2001 From: t9md Date: Tue, 21 Jul 2015 15:18:09 +0900 Subject: [PATCH] Use screenRowCount for MoveUp and MoveDown motion #785 --- lib/motions/general-motions.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/motions/general-motions.coffee b/lib/motions/general-motions.coffee index 47a3cc78..33a9089b 100644 --- a/lib/motions/general-motions.coffee +++ b/lib/motions/general-motions.coffee @@ -110,6 +110,13 @@ class Motion isInclusive: -> @vimState.mode is 'visual' or @operatesInclusively + getScreenRowCount: (cursor) -> + return 1 unless (@editor.isSoftWrapped() and @isLinewise()) + + bufferRow = cursor.getBufferRow() + bufferRowRange = new Range([bufferRow, 0], [bufferRow, Infinity]) + @editor.screenRangeForBufferRange(bufferRowRange).getRowCount() + class CurrentSelection extends Motion constructor: (@editor, @vimState) -> super(@editor, @vimState) @@ -167,7 +174,7 @@ class MoveUp extends Motion moveCursor: (cursor, count=1) -> _.times count, => unless cursor.getScreenRow() is 0 - cursor.moveUp() + cursor.moveUp(@getScreenRowCount(cursor)) @ensureCursorIsWithinLine(cursor) class MoveDown extends Motion @@ -176,7 +183,7 @@ class MoveDown extends Motion moveCursor: (cursor, count=1) -> _.times count, => unless cursor.getScreenRow() is @editor.getLastScreenRow() - cursor.moveDown() + cursor.moveDown(@getScreenRowCount(cursor)) @ensureCursorIsWithinLine(cursor) class MoveToPreviousWord extends Motion