@@ -110,7 +110,7 @@ class Motion
110110class CurrentSelection extends Motion
111111 constructor : (@editor , @vimState ) ->
112112 super (@editor , @vimState )
113- @lastSelection = @editor .getSelectedBufferRange ()
113+ @lastSelectionRange = @editor .getSelectedBufferRange ()
114114 @wasLinewise = @ isLinewise ()
115115
116116 execute : (count = 1 ) ->
@@ -128,32 +128,26 @@ class CurrentSelection extends Motion
128128 _ .times (count, -> true )
129129
130130 selectLines : ->
131- {start , end } = @lastSelection
132- lineCount = end .row - start .row
131+ lastSelectionExtent = @lastSelectionRange .getExtent ()
133132 for selection in @editor .getSelections ()
134133 cursor = selection .cursor .getBufferPosition ()
135- selection .setBufferRange
136- start :
137- row : cursor .row
138- column : 0
139- end :
140- row : cursor .row + end .row - start .row
141- column : 0
134+ selection .setBufferRange [[cursor .row , 0 ], [cursor .row + lastSelectionExtent .row , 0 ]]
135+ return
142136
143137 selectCharacters : ->
144- { start , end } = @lastSelection
145- if @lastSelection . isSingleLine ()
146- count = end . column - start . column
147- wrap = settings . wrapLeftRightMotion ()
148- for selection in @editor . getSelections ( )
149- _ . times count, ->
150- selection . selectRight () if wrap or not selection . cursor . isAtEndOfLine ()
151- else
152- for selection in @editor . getSelections ()
153- cursor = selection . cursor . getBufferPosition ()
154- selection .selectToBufferPosition
155- row : cursor . row + end . row - start . row
156- column : end . column
138+ lastSelectionExtent = @lastSelectionRange . getExtent ()
139+ wrap = settings . wrapLeftRightMotion ()
140+ for selection in @editor . getSelections ()
141+ { start } = selection . getBufferRange ()
142+ newEnd = start . traverse (lastSelectionExtent )
143+ selection . setBufferRange ([start, newEnd])
144+
145+ if wrap
146+ columnDifference = newEnd . column - selection . getBufferRange (). end . column
147+ if columnDifference > 0
148+ _ . times columnDifference, -> selection .selectRight ()
149+
150+ return
157151
158152# Public: Generic class for motions that require extra input
159153class MotionWithInput extends Motion
0 commit comments