From 881efd9c5da85496152ee0f2aae9e27ecbc64e43 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 20 Feb 2013 14:01:48 -0800 Subject: [PATCH] Restore selection when undoing an insert newline below --- spec/app/edit-session-spec.coffee | 8 ++++++++ src/app/edit-session.coffee | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/spec/app/edit-session-spec.coffee b/spec/app/edit-session-spec.coffee index 98169e109..51a1fa12f 100644 --- a/spec/app/edit-session-spec.coffee +++ b/spec/app/edit-session-spec.coffee @@ -1015,6 +1015,14 @@ describe "EditSession", -> expect(cursor2.getBufferPosition()).toEqual [8,0] describe ".insertNewlineBelow()", -> + describe "when the operation is undone", -> + it "places the cursor back at the previous location", -> + editSession.setCursorBufferPosition([0,2]) + editSession.insertNewlineBelow() + expect(editSession.getCursorBufferPosition()).toEqual [1,0] + editSession.undo() + expect(editSession.getCursorBufferPosition()).toEqual [0,2] + xit "inserts a newline below the cursor's current line, autoindents it, and moves the cursor to the end of the line", -> editSession.setAutoIndent(true) editSession.insertNewlineBelow() diff --git a/src/app/edit-session.coffee b/src/app/edit-session.coffee index 326d5dd4b..77e8360f2 100644 --- a/src/app/edit-session.coffee +++ b/src/app/edit-session.coffee @@ -171,8 +171,9 @@ class EditSession @insertText('\n') insertNewlineBelow: -> - @moveCursorToEndOfLine() - @insertNewline() + @transact => + @moveCursorToEndOfLine() + @insertNewline() insertNewlineAbove: -> @transact =>