 class Undo extends MiscCommand
   @extend()
 
-  withTrackingChanges: (fn) ->
+  setCursorPosition: ({newRanges, oldRanges, cursorContainedNewRangeOnly}) ->
+    lastCursor = @editor.getLastCursor() # This is restored cursor
+
+    if cursorContainedNewRangeOnly
+      changedRange = findRangeContainsPoint(newRanges, lastCursor.getBufferPosition())
+    else
+      changedRange = sortRanges(newRanges.concat(oldRanges))[0]
+
+    if changedRange?
+      if isLinewiseRange(changedRange)
+        setBufferRow(lastCursor, changedRange.start.row)
+      else
+        lastCursor.setBufferPosition(changedRange.start)
+
+  mutateWithTrackChanges: ->
     newRanges = []
     oldRanges = []
 

      @vimState.flash(flashRanges, options)

  execute: ->
    @withTrackingChanges =>
      @mutate()
    @activateMode('normal')

  mutate: ->

      else
        newRanges.push(newRange)

    @mutate()

    disposable.dispose()
    {newRanges, oldRanges}

  flashChanges: ({newRanges, oldRanges}) ->
    isMultipleSingleLineRanges = (ranges) ->
      ranges.length > 1 and ranges.every(isSingleLineRange)

    if newRanges.length > 0
      newRanges = newRanges.map(@humanizeNewLineForRange.bind(this))
      newRanges = @filterNonLeadingWhiteSpaceRange(newRanges)
      if isMultipleSingleLineRanges(newRanges)
        @flash(newRanges, type: 'undo-redo-multiple-changes')
      else
        @flash(newRanges, type: 'undo-redo')
    else
      if isMultipleSingleLineRanges(oldRanges)
        oldRanges = @filterNonLeadingWhiteSpaceRange(oldRanges)
        @flash(oldRanges, type: 'undo-redo-multiple-delete')

  filterNonLeadingWhiteSpaceRange: (ranges) ->
    ranges.filter (range) =>
