Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/motions/general-motions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down