diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 35e2f3dd8..ce9c64572 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -958,6 +958,15 @@ describe "Editor", -> editor.insertText('\n\n') expect(editor.scrollToPixelPosition.callCount).toBe 1 + it "autoscrolls on undo/redo", -> + spyOn(editor, 'scrollToPixelPosition') + editor.insertText('\n\n') + expect(editor.scrollToPixelPosition.callCount).toBe 1 + editor.undo() + expect(editor.scrollToPixelPosition.callCount).toBe 2 + editor.redo() + expect(editor.scrollToPixelPosition.callCount).toBe 3 + describe "when the last cursor exceeds the upper or lower scroll margins", -> describe "when the editor is taller than twice the vertical scroll margin", -> it "sets the scrollTop so the cursor remains within the scroll margin", -> diff --git a/src/edit-session.coffee b/src/edit-session.coffee index 2cc8397e2..5625da8d3 100644 --- a/src/edit-session.coffee +++ b/src/edit-session.coffee @@ -574,10 +574,12 @@ class EditSession # Public: Undoes the last change. undo: -> + @getCursor().needsAutoscroll = true @buffer.undo(this) # Pulic: Redoes the last change. redo: -> + @getCursor().needsAutoscroll = true @buffer.redo(this) # Public: Folds all the rows.