mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Don't move trailing newline for multiline selections
This commit is contained in:
@@ -2351,6 +2351,15 @@ describe "Editor", ->
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[2, 4], [3, 0]]
|
||||
expect(editor.isFoldedAtScreenRow(3)).toBeTruthy()
|
||||
|
||||
describe "when an entire line is selected including the newline", ->
|
||||
it "moves the selected line up", ->
|
||||
editor.setCursorBufferPosition([1])
|
||||
editor.selectToEndOfLine()
|
||||
editor.selectRight()
|
||||
editor.trigger 'editor:move-line-up'
|
||||
expect(buffer.lineForRow(0)).toBe ' var sort = function(items) {'
|
||||
expect(buffer.lineForRow(1)).toBe 'var quicksort = function () {'
|
||||
|
||||
describe "when editor:move-line-down is triggered", ->
|
||||
describe "when there is no selection", ->
|
||||
it "moves the line where the cursor is down", ->
|
||||
@@ -2435,3 +2444,12 @@ describe "Editor", ->
|
||||
expect(buffer.lineForRow(5)).toBe ' while(items.length > 0) {'
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[4, 4], [5, 0]]
|
||||
expect(editor.isFoldedAtScreenRow(5)).toBeTruthy()
|
||||
|
||||
describe "when an entire line is selected including the newline", ->
|
||||
it "moves the selected line down", ->
|
||||
editor.setCursorBufferPosition([1])
|
||||
editor.selectToEndOfLine()
|
||||
editor.selectRight()
|
||||
editor.trigger 'editor:move-line-down'
|
||||
expect(buffer.lineForRow(1)).toBe ' if (items.length <= 1) return items;'
|
||||
expect(buffer.lineForRow(2)).toBe ' var sort = function(items) {'
|
||||
|
||||
@@ -342,7 +342,10 @@ class EditSession
|
||||
|
||||
@transact =>
|
||||
foldedRows = []
|
||||
for row in [selection.start.row..selection.end.row]
|
||||
rows = [selection.start.row..selection.end.row]
|
||||
if selection.start.row isnt selection.end.row and selection.end.column is 0
|
||||
rows.pop() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row)
|
||||
for row in rows
|
||||
screenRow = @screenPositionForBufferPosition([row]).row
|
||||
if @isFoldedAtScreenRow(screenRow)
|
||||
bufferRange = @bufferRangeForScreenRange([[screenRow], [screenRow + 1]])
|
||||
@@ -374,7 +377,10 @@ class EditSession
|
||||
|
||||
@transact =>
|
||||
foldedRows = []
|
||||
for row in [selection.end.row..selection.start.row]
|
||||
rows = [selection.end.row..selection.start.row]
|
||||
if selection.start.row isnt selection.end.row and selection.end.column is 0
|
||||
rows.shift() unless @isFoldedAtScreenRow(@screenPositionForBufferPosition(selection.end).row)
|
||||
for row in rows
|
||||
screenRow = @screenPositionForBufferPosition([row]).row
|
||||
if @isFoldedAtScreenRow(screenRow)
|
||||
bufferRange = @bufferRangeForScreenRange([[screenRow], [screenRow + 1]])
|
||||
|
||||
Reference in New Issue
Block a user