     selection.collapseToStart() if selection.type == "Range"
     selection.getRangeAt 0
 
-findModeSaveSelection = ->
-  findModeInitialRange = getCurrentRange()
-
-findModeRestoreSelection = (range = findModeInitialRange) ->
+findModeRestoreSelection = ->
+  range = findMode.initialRange
   selection = getSelection()
   selection.removeAllRanges()
   selection.addRange range

window.findMode = null
window.findModeQueryHasResults = false
findModeAnchorNode = null
findModeInitialRange = null
isShowingHelpDialog = false
keyPort = null
isEnabledForUrl = true

class FindMode extends Mode
  constructor: (@options = {}) ->
    # Save the selection, so performFindInPlace can restore it.
    @initialRange = getCurrentRange()
    window.findModeQuery = rawQuery: ""
    if @options.returnToViewport
      @scrollX = window.scrollX
