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

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

        @editor.setCursorBufferPosition(range.start)

    if settings.get('flashOnUndoRedo')
      trimStartingNewLine = @trimStartingNewLine.bind(this)
      @onDidFinishOperation =>
        @vimState.flash(newRanges.map(trimStartingNewLine), type: 'removed')
        @vimState.flash(oldRanges.map(trimStartingNewLine), type: 'added')

  execute: ->
    @withTrackingChanges =>
