+_ = require 'underscore'
+
 module.exports =
+
 class UndoManager
   undoHistory: null
   redoHistory: null

      @preservingHistory =>
        opsInReverse = new Array(batch...)
        opsInReverse.reverse()
        for op in opsInReverse
          @buffer.change op.newRange, op.oldText
        @redoHistory.push batch
      batch.oldSelectionRanges

  redo: ->
    if batch = @redoHistory.pop()
      @preservingHistory =>
        for op in batch
          @buffer.change op.oldRange, op.newText
        @undoHistory.push batch
      batch.newSelectionRanges

  startUndoBatch: (ranges) ->

    fn()
    @preserveHistory = false

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

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

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