mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge pull request #12946 from jamsinclair/11848-fix-moving-line-without-line-ending
Fixes #11848 Moving line up without line ending
This commit is contained in:
@@ -2761,6 +2761,22 @@ describe "TextEditor", ->
|
||||
expect(editor.isFoldedAtBufferRow(6)).toBeFalsy()
|
||||
expect(editor.lineTextForBufferRow(6)).toBe " if (items.length <= 1) return items;"
|
||||
|
||||
describe "when the last line of selection does not end with a valid line ending", ->
|
||||
it "appends line ending to last line and moves the lines spanned by the selection to the preceeding row", ->
|
||||
expect(editor.lineTextForBufferRow(9)).toBe " };"
|
||||
expect(editor.lineTextForBufferRow(10)).toBe ""
|
||||
expect(editor.lineTextForBufferRow(11)).toBe " return sort(Array.apply(this, arguments));"
|
||||
expect(editor.lineTextForBufferRow(12)).toBe "};"
|
||||
|
||||
editor.setSelectedBufferRange([[10, 0], [12, 2]])
|
||||
editor.moveLineUp()
|
||||
|
||||
expect(editor.getSelectedBufferRange()).toEqual [[9, 0], [11, 2]]
|
||||
expect(editor.lineTextForBufferRow(9)).toBe ""
|
||||
expect(editor.lineTextForBufferRow(10)).toBe " return sort(Array.apply(this, arguments));"
|
||||
expect(editor.lineTextForBufferRow(11)).toBe "};"
|
||||
expect(editor.lineTextForBufferRow(12)).toBe " };"
|
||||
|
||||
describe "when there are multiple selections", ->
|
||||
describe "when all the selections span different lines", ->
|
||||
describe "when there is no folds", ->
|
||||
|
||||
@@ -1162,7 +1162,7 @@ class TextEditor extends Model
|
||||
|
||||
# Delete lines spanned by selection and insert them on the preceding buffer row
|
||||
lines = @buffer.getTextInRange(linesRange)
|
||||
lines += @buffer.lineEndingForRow(linesRange.end.row - 1) unless lines[lines.length - 1] is '\n'
|
||||
lines += @buffer.lineEndingForRow(linesRange.end.row - 2) unless lines[lines.length - 1] is '\n'
|
||||
@buffer.delete(linesRange)
|
||||
@buffer.insert([precedingRow, 0], lines)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user