From 84e723a72349c7539cf7175282081809ecbaebbb Mon Sep 17 00:00:00 2001 From: joseramonc Date: Sat, 10 Oct 2015 13:15:05 -0500 Subject: [PATCH 1/2] autoindent lines in moveLineUp/moveLineDown #7546 --- src/text-editor.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/text-editor.coffee b/src/text-editor.coffee index 4d517ac99..03c3fc7aa 100644 --- a/src/text-editor.coffee +++ b/src/text-editor.coffee @@ -842,6 +842,7 @@ class TextEditor extends Model @foldBufferRow(foldedRow) @setSelectedBufferRange(selection.translate([-insertDelta]), preserveFolds: true, autoscroll: true) + @autoIndentSelectedRows() if @shouldAutoIndent() # Move lines intersecting the most recent selection down by one row in screen # coordinates. @@ -898,6 +899,7 @@ class TextEditor extends Model @foldBufferRow(foldedRow) @setSelectedBufferRange(selection.translate([insertDelta]), preserveFolds: true, autoscroll: true) + @autoIndentSelectedRows() if @shouldAutoIndent() # Duplicate the most recent cursor's current line. duplicateLines: -> From 29dfd1c904a529a683231f034179a684896f5a3d Mon Sep 17 00:00:00 2001 From: joseramonc Date: Tue, 13 Oct 2015 21:07:46 -0500 Subject: [PATCH 2/2] add moveLineUp and moveLineDown specs --- spec/text-editor-spec.coffee | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/text-editor-spec.coffee b/spec/text-editor-spec.coffee index e95818900..a37b26da7 100644 --- a/spec/text-editor-spec.coffee +++ b/spec/text-editor-spec.coffee @@ -4145,6 +4145,37 @@ describe "TextEditor", -> """ expect(editor.getSelectedBufferRange()).toEqual [[13, 0], [14, 2]] + describe ".moveLineUp()", -> + it "moves line up", -> + editor.setCursorBufferPosition([1, 0]) + editor.moveLineUp() + expect(editor.getTextInBufferRange([[0, 0], [0, 30]])).toBe " var sort = function(items) {" + expect(editor.indentationForBufferRow(0)).toBe 1 + expect(editor.indentationForBufferRow(1)).toBe 0 + + it "update indentation when config editor.autoIndent is true", -> + atom.config.set('editor.autoIndent', true) + editor.setCursorBufferPosition([1, 0]) + editor.moveLineUp() + expect(editor.indentationForBufferRow(0)).toBe 0 + expect(editor.indentationForBufferRow(1)).toBe 0 + + describe ".moveLineDown()", -> + it "moves line down", -> + editor.setCursorBufferPosition([0, 0]) + editor.moveLineDown() + expect(editor.getTextInBufferRange([[1, 0], [1, 31]])).toBe "var quicksort = function () {" + expect(editor.indentationForBufferRow(0)).toBe 1 + expect(editor.indentationForBufferRow(1)).toBe 0 + + it "update indentation when config editor.autoIndent is true", -> + atom.config.set('editor.autoIndent', true) + editor.setCursorBufferPosition([0, 0]) + editor.moveLineDown() + expect(editor.indentationForBufferRow(0)).toBe 1 + expect(editor.indentationForBufferRow(1)).toBe 2 + + describe ".shouldPromptToSave()", -> it "returns false when an edit session's buffer is in use by more than one session", -> jasmine.unspy(editor, 'shouldPromptToSave')