From 36bcb542a81bb75d3ea1653976115c57c618384f Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 3 May 2016 11:50:02 +0200 Subject: [PATCH] Don't move down a line if it's the last buffer row --- spec/text-editor-spec.coffee | 7 +++++++ src/text-editor.coffee | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index 8affb9b5f..c8156cdd0 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -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 -> diff --git a/src/text-editor.coffee b/src/text-editor.coffee index e3902b88c..b778491d1 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -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)