diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index 290710df7..f6b4b78dd 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -792,6 +792,12 @@ describe "Editor", -> editor.insertNewline() expect(editor.getScrollBottom()).toBe 15 * 10 + it "autoscrolls to the cursor when it moves due to undo", -> + editor.insertText('abc') + editor.setScrollTop(Infinity) + editor.undo() + expect(editor.getScrollTop()).toBe 0 + describe "selection", -> selection = null diff --git a/src/cursor.coffee b/src/cursor.coffee index 7ab62ae81..58bf31395 100644 --- a/src/cursor.coffee +++ b/src/cursor.coffee @@ -28,6 +28,7 @@ class Cursor extends Model # Supports old editor view @needsAutoscroll ?= @isLastCursor() and !textChanged + @autoscroll() if @editor.manageScrollPosition and @isLastCursor() and textChanged @goalColumn = null diff --git a/src/selection.coffee b/src/selection.coffee index 93bebbe7c..c34374299 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -326,8 +326,6 @@ class Selection extends Model newBufferRange = @editor.buffer.setTextInRange(oldBufferRange, text, pick(options, 'undo')) - @cursor.autoscroll() if @editor.manageScrollPosition and @cursor.isLastCursor() - if options.select @setBufferRange(newBufferRange, reversed: wasReversed) else