mirror of
https://github.com/atom/atom.git
synced 2026-02-09 22:24:59 -05:00
UndoManager's batch methods take optional arrays of ranges for restoring the selection
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
48b4008cab
commit
5def158584
@@ -17,25 +17,29 @@ class UndoManager
|
||||
@redoHistory = []
|
||||
|
||||
undo: ->
|
||||
if ops = @undoHistory.pop()
|
||||
if batch = @undoHistory.pop()
|
||||
@preservingHistory =>
|
||||
opsInReverse = new Array(ops...)
|
||||
opsInReverse = new Array(batch...)
|
||||
opsInReverse.reverse()
|
||||
for op in opsInReverse
|
||||
@buffer.change op.newRange, op.oldText
|
||||
@redoHistory.push ops
|
||||
@redoHistory.push batch
|
||||
batch.oldSelectionRanges
|
||||
|
||||
redo: ->
|
||||
if ops = @redoHistory.pop()
|
||||
if batch = @redoHistory.pop()
|
||||
@preservingHistory =>
|
||||
for op in ops
|
||||
for op in batch
|
||||
@buffer.change op.oldRange, op.newText
|
||||
@undoHistory.push ops
|
||||
@undoHistory.push batch
|
||||
batch.newSelectionRanges
|
||||
|
||||
startUndoBatch: ->
|
||||
startUndoBatch: (ranges) ->
|
||||
@currentBatch = []
|
||||
@currentBatch.oldSelectionRanges = ranges
|
||||
|
||||
endUndoBatch: ->
|
||||
endUndoBatch: (ranges) ->
|
||||
@currentBatch.newSelectionRanges = ranges
|
||||
@undoHistory.push(@currentBatch)
|
||||
@currentBatch = null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user