 
 {
   pointIsAtEndOfLine
-  mergeIntersectingRanges
   sortRanges
 } = require './utils'
 

class Undo extends MiscCommand
  @extend()

  withTrackingChanges: (fn) ->
    newRanges = []
    oldRanges = []

    disposable = @editor.getBuffer().onDidChange (event) ->
      {oldRange, newRange, oldText, newText} = event

      if newRange.containsRange(oldRange)
        newRanges.push(newRange)
        return

    fn()

    disposable.dispose()

    if range = sortRanges(_.compact([newRanges[0], _.last(oldRanges)]))[0]
      @vimState.mark.setRange('[', ']', range)
