mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
🎨 select-line adjustments; Only select single row if row is given
This commit is contained in:
@@ -56,6 +56,19 @@ describe "Selection", ->
|
||||
selection.selectToScreenPosition([0, 25])
|
||||
expect(selection.isReversed()).toBeFalsy()
|
||||
|
||||
describe ".selectLine(row)", ->
|
||||
describe "when passed a row", ->
|
||||
it "selects the specified row", ->
|
||||
selection.setBufferRange([[2, 4], [3, 4]])
|
||||
selection.selectLine(5)
|
||||
expect(selection.getBufferRange()).toEqual [[5, 0], [6, 0]]
|
||||
|
||||
describe "when not passed a row", ->
|
||||
it "selects all rows spanned by the selection", ->
|
||||
selection.setBufferRange([[2, 4], [3, 4]])
|
||||
selection.selectLine()
|
||||
expect(selection.getBufferRange()).toEqual [[2, 0], [4, 0]]
|
||||
|
||||
describe "when only the selection's tail is moved (regression)", ->
|
||||
it "notifies ::onDidChangeRange observers", ->
|
||||
selection.setBufferRange([[2, 0], [2, 10]], reversed: true)
|
||||
|
||||
@@ -1284,7 +1284,7 @@ describe "TextEditor", ->
|
||||
expect(selection2.isReversed()).toBeFalsy()
|
||||
|
||||
describe ".selectLinesContainingCursors()", ->
|
||||
it "selects the entire line (including newlines) at given row", ->
|
||||
it "selects to the entire line (including newlines) at given row", ->
|
||||
editor.setCursorScreenPosition([1, 2])
|
||||
editor.selectLinesContainingCursors()
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[1, 0], [2, 0]]
|
||||
@@ -1299,8 +1299,8 @@ describe "TextEditor", ->
|
||||
editor.selectLinesContainingCursors()
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[0, 0], [2, 0]]
|
||||
|
||||
describe "when selection span multiple row", ->
|
||||
it "complete selection to contain the entire first and last line", ->
|
||||
describe "when the selection spans multiple row", ->
|
||||
it "selects from the beginning of the first line to the last line", ->
|
||||
selection = editor.getLastSelection()
|
||||
selection.setBufferRange [[1, 10], [3, 20]]
|
||||
editor.selectLinesContainingCursors()
|
||||
|
||||
@@ -324,17 +324,12 @@ class Selection extends Model
|
||||
#
|
||||
# * `row` The line {Number} to select (default: the row of the cursor).
|
||||
selectLine: (row, options) ->
|
||||
|
||||
if row?
|
||||
range = @editor.bufferRangeForBufferRow(row, includeNewline: true)
|
||||
@setBufferRange(@getBufferRange().union(range), options)
|
||||
|
||||
@setBufferRange(@editor.bufferRangeForBufferRow(row, includeNewline: true), options)
|
||||
else
|
||||
rowStart = @marker.getStartBufferPosition().row
|
||||
rangeStart = @editor.bufferRangeForBufferRow(rowStart, includeNewline: true)
|
||||
rowEnd = @marker.getEndBufferPosition().row
|
||||
rangeEnd = @editor.bufferRangeForBufferRow(rowEnd, includeNewline: true)
|
||||
@setBufferRange(@getBufferRange().union(rangeStart).union(rangeEnd), options)
|
||||
startRange = @editor.bufferRangeForBufferRow(@marker.getStartBufferPosition().row)
|
||||
endRange = @editor.bufferRangeForBufferRow(@marker.getEndBufferPosition().row, includeNewline: true)
|
||||
@setBufferRange(startRange.union(endRange), options)
|
||||
|
||||
@linewise = true
|
||||
@wordwise = false
|
||||
|
||||
Reference in New Issue
Block a user