Don't move down a line if it's the last buffer row

This commit is contained in:
Antonio Scandurra
2016-05-03 11:50:02 +02:00
parent f4a31261d0
commit 36bcb542a8
2 changed files with 8 additions and 1 deletions

View File

@@ -2875,6 +2875,13 @@ describe "TextEditor", ->
expect(editor.lineTextForBufferRow(1)).toBe "1"
expect(editor.lineTextForBufferRow(2)).toBe "2"
describe "when the line is the last buffer row", ->
it "doesn't move it", ->
editor.setText("abc\ndef")
editor.setCursorBufferPosition([1, 0])
editor.moveLineDown()
expect(editor.getText()).toBe("abc\ndef")
describe ".insertText(text)", ->
describe "when there is a single selection", ->
beforeEach ->

View File

@@ -1068,7 +1068,7 @@ class TextEditor extends Model
# Delete lines spanned by selection and insert them on the following correct buffer row
lines = @buffer.getTextInRange(linesRange)
if linesRange.end.row is @buffer.getLastRow()
if followingRow - 1 is @buffer.getLastRow()
lines = "\n#{lines}"
@buffer.insert([followingRow, 0], lines)