Don't skip shorter lines when the adding empty selection below

This commit is contained in:
Nathan Sobo 2013-04-05 11:40:03 -06:00
parent 131df22c11
commit 393cba4d42
2 changed files with 25 additions and 6 deletions

View File

@ -756,6 +756,19 @@ describe "EditSession", ->
[[6, 22], [6, 28]]
]
describe "when the selection is empty", ->
it "does not skip lines that are shorter than the current column", ->
editSession.setCursorBufferPosition([3, 36])
editSession.addSelectionBelow()
editSession.addSelectionBelow()
editSession.addSelectionBelow()
expect(editSession.getSelectedBufferRanges()).toEqual [
[[3, 36], [3, 36]]
[[4, 29], [4, 29]]
[[5, 30], [5, 30]]
[[6, 36], [6, 36]]
]
describe "when the cursor is moved while there is a selection", ->
makeSelection = -> selection.setBufferRange [[1, 2], [1, 5]]

View File

@ -155,12 +155,18 @@ class Selection
addSelectionBelow: ->
range = (@goalBufferRange ? @getBufferRange()).copy()
nextRow = range.end.row + 1
for row in [nextRow..@editSession.getLastBufferRow()]
range.start.row = row
range.end.row = row
unless @editSession.clipBufferRange(range).isEmpty()
@editSession.addSelectionForBufferRange(range, goalBufferRange: range, suppressMerge: true)
break
if range.isEmpty()
range.start.row = nextRow
range.end.row = nextRow
@editSession.addSelectionForBufferRange(range, goalBufferRange: range, suppressMerge: true)
else
for row in [nextRow..@editSession.getLastBufferRow()]
range.start.row = row
range.end.row = row
unless @editSession.clipBufferRange(range).isEmpty()
@editSession.addSelectionForBufferRange(range, goalBufferRange: range, suppressMerge: true)
break
insertText: (text, options={}) ->
oldBufferRange = @getBufferRange()