diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index bc227d76b..290710df7 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -785,6 +785,13 @@ describe "Editor", -> editor.moveCursorLeft() expect(editor.getScrollLeft()).toBe 58 * 10 + it "scrolls down when inserting lines makes the document longer than the editor's height", -> + editor.setCursorScreenPosition([13, Infinity]) + editor.insertNewline() + expect(editor.getScrollBottom()).toBe 14 * 10 + editor.insertNewline() + expect(editor.getScrollBottom()).toBe 15 * 10 + describe "selection", -> selection = null diff --git a/src/selection.coffee b/src/selection.coffee index 2945801d4..5990bec9f 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -315,12 +315,14 @@ class Selection extends Model wasReversed = @isReversed() @clear() @cursor.needsAutoscroll = @cursor.isLastCursor() - @cursor.autoscroll() if @editor.manageScrollPosition and @cursor.isLastCursor() if options.indentBasis? and not options.autoIndent text = @normalizeIndents(text, options.indentBasis) 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