diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index b8cb46d7b..6092dd662 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -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]] diff --git a/src/app/selection.coffee b/src/app/selection.coffee index 40f1ad389..6c37b2291 100644 --- a/src/app/selection.coffee +++ b/src/app/selection.coffee @@ -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()