     @startBatchCallCount = 0
     @undoHistory = []
     @redoHistory = []
-    @buffer.on 'change', (op) =>
+    @buffer.on 'change', (event) =>
       unless @preserveHistory
+        op = new BufferChangeOperation(_.extend({ @buffer }, event))
         if @currentBatch
           @currentBatch.push(op)
         else

module.exports =
class UndoManager
  undoHistory: null
  redoHistory: null

    fn()
    @preserveHistory = false

class BufferChangeOperation
  constructor: ({@buffer, @oldRange, @newRange, @oldText, @newText}) ->

  do: ->
    @buffer.change @oldRange, @newText

  undo: ->
    @buffer.change @newRange, @oldText
