When snippet expansion is undone, the snippet is destroyed

This is still in progress. You can't *redo* snippet expansion and restore tab stops. Also, this commit performs all changes associated with snippet expansion in a transaction.
This commit is contained in:
Corey Johnson & Nathan Sobo
2012-07-06 12:09:45 -06:00
parent 6177b46cf9
commit 9f9c636883
7 changed files with 21 additions and 18 deletions

View File

@@ -142,9 +142,9 @@ class Buffer
@lines[startRow..endRow] = newLines
@modified = true
pushOperation: (operation) ->
pushOperation: (operation, editSession) ->
if @undoManager
@undoManager.pushOperation(operation)
@undoManager.pushOperation(operation, editSession)
else
operation.do()

View File

@@ -238,16 +238,19 @@ class EditSession
transact: (fn) ->
@buffer.transact =>
oldSelectedRanges = @getSelectedBufferRanges()
@buffer.pushOperation
@pushOperation
undo: (editSession) ->
editSession?.setSelectedBufferRanges(oldSelectedRanges)
fn()
newSelectedRanges = @getSelectedBufferRanges()
@buffer.pushOperation
@pushOperation
redo: (editSession) ->
editSession?.setSelectedBufferRanges(newSelectedRanges)
pushOperation: (operation) ->
@buffer.pushOperation(operation, this)
getAnchors: ->
new Array(@anchors...)

View File

@@ -12,13 +12,13 @@ class UndoManager
@undoHistory = []
@redoHistory = []
pushOperation: (operation) ->
pushOperation: (operation, editSession) ->
if @currentTransaction
@currentTransaction.push(operation)
else
@undoHistory.push([operation])
@redoHistory = []
operation.do?()
operation.do?(editSession)
transact: (fn) ->
if @currentTransaction