diff --git a/spec/editor-spec.coffee b/spec/editor-spec.coffee index d697b7491..bc227d76b 100644 --- a/spec/editor-spec.coffee +++ b/spec/editor-spec.coffee @@ -1483,6 +1483,17 @@ describe "Editor", -> expect(cursor1.getBufferPosition()).toEqual [1, 5] expect(cursor2.getBufferPosition()).toEqual [2, 7] + it "autoscrolls to the last cursor", -> + editor.manageScrollPosition = true + editor.setCursorScreenPosition([1, 2]) + editor.addCursorAtScreenPosition([10, 4]) + editor.setLineHeightInPixels(10) + editor.setHeight(50) + + expect(editor.getScrollTop()).toBe 0 + editor.insertText('a') + expect(editor.getScrollTop()).toBe 80 + describe "when there are multiple non-empty selections", -> describe "when the selections are on the same line", -> it "replaces each selection range with the inserted characters", -> diff --git a/src/selection.coffee b/src/selection.coffee index c27f63f92..2945801d4 100644 --- a/src/selection.coffee +++ b/src/selection.coffee @@ -315,6 +315,7 @@ 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)