Autoscroll to the last cursor in model when inserting text

Fixes #2787
This commit is contained in:
Nathan Sobo
2014-07-01 11:34:36 -06:00
parent d4a7bff525
commit e93e4e9333
2 changed files with 12 additions and 0 deletions

View File

@@ -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", ->

View File

@@ -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)