         for rangeToRefold in rangesToRefold
           @displayBuffer.createFold(rangeToRefold.start.row, rangeToRefold.end.row)
 
-        for selection, i in selectionsToMove
-          newSelectionRanges.push(rangesOfSelectionsToMove[i].translate([-insertDelta, 0]))
+        for selection in selectionsToMove
+          newSelectionRanges.push(selection.translate([-insertDelta, 0]))
 
       @setSelectedBufferRanges(newSelectionRanges)
 


        # Make sure the inserted text doesn't go into an existing fold
        if fold = @displayBuffer.largestFoldStartingAtBufferRow(precedingBufferRow)
          rangesToRefold.push(fold.getBufferRange().translate([linesRange.getRowCount(), 0]))
          fold.destroy()

        # Delete lines spanned by selection and insert them on the preceding buffer row

  # Move lines intersection the most recent selection or multiple selections up by one row in screen
  # coordinates.
  moveLineUp: ->
    selections = @getSelectedBufferRanges()
    selections.sort (a, b) -> a.compare(b)

    if selections[0].start.row is 0
      return

    if selections[selections.length - 1].start.row is @getLastBufferRow() and @buffer.getLastLine() is ''
      return

    @transact =>
