No longer push empty batches onto undo stack

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-04-10 10:25:22 -07:00
parent afceacefc8
commit fa50e9705e
2 changed files with 10 additions and 1 deletions

View File

@@ -136,3 +136,12 @@ describe "UndoManager", ->
expect(buffer.lineForRow(4)).not.toContain("while")
expect(buffer.lineForRow(4)).toContain("slongaz")
it "does not store empty batches", ->
buffer.insert([0,0], "foo")
undoManager.startUndoBatch()
undoManager.endUndoBatch()
undoManager.undo()
expect(buffer.lineForRow(0)).not.toContain("foo")

View File

@@ -40,7 +40,7 @@ class UndoManager
endUndoBatch: (ranges) ->
@currentBatch.newSelectionRanges = ranges
@undoHistory.push(@currentBatch)
@undoHistory.push(@currentBatch) if @currentBatch.length > 0
@currentBatch = null
preservingHistory: (fn) ->