   # Save the selection, so performFindInPlace can restore it.
   findModeSaveSelection()
   window.findModeQuery = rawQuery: ""
-  findMode = new FindMode options
+  window.findMode = new FindMode options
   HUD.showFindMode()
   findMode
 

#

window.findModeQuery = { rawQuery: "", matchCount: 0 }
findModeQueryHasResults = false
findModeAnchorNode = null
findModeInitialRange = null

      exitOnClick: true

      keydown: (event) =>
        window.scrollTo findMode.scrollX, findMode.scrollY if findMode.options.returnToViewport
        if event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey
          findMode.exit()
          new PostFindMode if findModeQueryHasResults
        else if event.keyCode == keyCodes.enter
          handleEnterForFindMode()
          findMode.exit()
          new PostFindMode if findModeQueryHasResults
        else if event.keyCode == keyCodes.upArrow
          if rawQuery = FindModeHistory.getQuery findMode.historyIndex + 1
            findMode.historyIndex += 1
            findMode.partialQuery = findModeQuery.rawQuery if findMode.historyIndex == 0
            HUD.showFindMode rawQuery
        else if event.keyCode == keyCodes.downArrow
          findMode.historyIndex = Math.max -1, findMode.historyIndex - 1
          rawQuery = if 0 <= findMode.historyIndex then FindModeHistory.getQuery findMode.historyIndex else findMode.partialQuery
          HUD.showFindMode rawQuery
        else if KeyboardUtils.isEscape event
          findMode.exit()
          handleEscapeForFindMode()
          new PostFindMode if findModeQueryHasResults

