Autoscroll *after* inserting text, not before

Fixes #2787
This commit is contained in:
Nathan Sobo
2014-07-03 14:47:28 -06:00
parent 6c8b4de986
commit 260be2e096
2 changed files with 10 additions and 1 deletions

View File

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

View File

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