Make Buffer.transact restore marker ranges on undo/redo of transaction

We no longer need to restore selection ranges before and after
transactions now because selections are based on markers so they go
along for the ride for free. This allows us to delegate directly to
Buffer.transact from EditSession.
This commit is contained in:
Nathan Sobo
2013-05-01 18:38:40 -06:00
parent 988f4da6e1
commit 69300e0766
7 changed files with 90 additions and 149 deletions

View File

@@ -618,26 +618,11 @@ class EditSession
# Internal #
###
transact: (fn) ->
isNewTransaction = @buffer.transact()
oldSelectedRanges = @getSelectedBufferRanges()
@pushOperation
undo: (editSession) ->
editSession?.setSelectedBufferRanges(oldSelectedRanges, preserveFolds: true)
if fn
result = fn()
@commit() if isNewTransaction
result
transact: (fn) -> @buffer.transact(fn)
commit: ->
newSelectedRanges = @getSelectedBufferRanges()
@pushOperation
redo: (editSession) ->
editSession?.setSelectedBufferRanges(newSelectedRanges, preserveFolds: true)
@buffer.commit()
commit: -> @buffer.commit()
abort: ->
@buffer.abort()
abort: -> @buffer.abort()
###
# Public #