@@ -166,18 +166,22 @@ class MoveUpDown extends Motion
166166 direction : null
167167
168168 getScreenRowCount : (cursor ) ->
169- unless (@ isLinewise () and @editor .isSoftWrapped ())
170- return 1
171- else
172- cursorBufferRow = cursor .getBufferRow ()
173- cursorLineBufferRange = [[cursorBufferRow, 0 ], [cursorBufferRow, Infinity ]]
174- cursorLineScreenRange = @editor .screenRangeForBufferRange (cursorLineBufferRange)
175- cursorLineScreenRange .getRowCount ()
169+ return 1 unless (@ isLinewise () and @editor .isSoftWrapped ())
170+
171+ cursorBufferRow = cursor .getBufferRow ()
172+ cursorLineBufferRange = [[cursorBufferRow, 0 ], [cursorBufferRow, Infinity ]]
173+ cursorLineScreenRange = @editor .screenRangeForBufferRange (cursorLineBufferRange)
174+ cursorLineScreenRange .getRowCount ()
176175
177176 moveCursor : (cursor , count = 1 ) ->
178177 _ .times count, =>
179- unless cursor .getScreenRow () is 0
180- cursor[" move#{ @direction } " ](@ getScreenRowCount (cursor))
178+ screenRowCount = @ getScreenRowCount (cursor)
179+
180+ if (@direction is ' Up' ) and not (cursor .getScreenRow () is 0 )
181+ cursor .moveUp (screenRowCount)
182+ @ ensureCursorIsWithinLine (cursor)
183+ else if (@direction is ' Down' ) and not (cursor .getScreenRow () is @editor .getLastScreenRow ())
184+ cursor .moveDown (screenRowCount)
181185 @ ensureCursorIsWithinLine (cursor)
182186
183187class MoveUp extends MoveUpDown
0 commit comments