mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-12-28 17:13:45 +03:00
Mark last cursor for autoscroll on undo/redo
This commit is contained in:
parent
dba7687470
commit
291f4fbb90
@ -958,6 +958,16 @@ describe "Editor", ->
|
||||
editor.insertText('\n\n')
|
||||
expect(editor.scrollToPixelPosition.callCount).toBe 1
|
||||
|
||||
it "autoscrolls on undo/redo", ->
|
||||
editor.getCursor().clearAutoscroll()
|
||||
spyOn(editor, 'scrollToPixelPosition').andCallThrough()
|
||||
editor.insertText('\n\n')
|
||||
expect(editor.scrollToPixelPosition.callCount).toBe 1
|
||||
editor.undo()
|
||||
expect(editor.scrollToPixelPosition.callCount).toBe 2
|
||||
editor.redo()
|
||||
expect(editor.scrollToPixelPosition.callCount).toBe 3
|
||||
|
||||
describe "when the last cursor exceeds the upper or lower scroll margins", ->
|
||||
describe "when the editor is taller than twice the vertical scroll margin", ->
|
||||
it "sets the scrollTop so the cursor remains within the scroll margin", ->
|
||||
|
@ -27,7 +27,7 @@ class Cursor
|
||||
{textChanged} = e
|
||||
return if oldHeadScreenPosition.isEqual(newHeadScreenPosition)
|
||||
|
||||
@needsAutoscroll ?= @isLastCursor()
|
||||
@needsAutoscroll ?= @isLastCursor() and !textChanged
|
||||
|
||||
movedEvent =
|
||||
oldBufferPosition: oldHeadBufferPosition
|
||||
|
@ -574,10 +574,14 @@ class EditSession
|
||||
|
||||
# Public: Undoes the last change.
|
||||
undo: ->
|
||||
cursor = @getCursor()
|
||||
cursor.needsAutoscroll = cursor.isLastCursor()
|
||||
@buffer.undo(this)
|
||||
|
||||
# Pulic: Redoes the last change.
|
||||
redo: ->
|
||||
cursor = @getCursor()
|
||||
cursor.needsAutoscroll = cursor.isLastCursor()
|
||||
@buffer.redo(this)
|
||||
|
||||
# Public: Folds all the rows.
|
||||
|
Loading…
Reference in New Issue
Block a user