       exitOnClick: true
 
       keydown: (event) =>
-        window.scrollTo @scrollX, @scrollY if options.returnToViewport
+        window.scrollTo findMode.scrollX, findMode.scrollY if findMode.options.returnToViewport
         if event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey
-          HUD.hide()
-          @exit()
+          findMode.exit()
           new PostFindMode if findModeQueryHasResults
         else if event.keyCode == keyCodes.enter
           handleEnterForFindMode()
-          @exit()
+          findMode.exit()
           new PostFindMode if findModeQueryHasResults
         else if event.keyCode == keyCodes.upArrow
-          if rawQuery = FindModeHistory.getQuery @historyIndex + 1
-            @historyIndex += 1
-            @partialQuery = findModeQuery.rawQuery if @historyIndex == 0
+          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
-          @historyIndex = Math.max -1, @historyIndex - 1
-          rawQuery = if 0 <= @historyIndex then FindModeHistory.getQuery @historyIndex else @partialQuery
+          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
-          @exit()
+          findMode.exit()
           handleEscapeForFindMode()
           new PostFindMode if findModeQueryHasResults
 

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


#

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