   FindModeHistory.saveQuery findModeQuery.rawQuery
 
 class FindMode extends Mode
-  constructor: (options = {}) ->
+  constructor: (@options = {}) ->
     @historyIndex = -1
     @partialQuery = ""
-    if options.returnToViewport
+    if @options.returnToViewport
       @scrollX = window.scrollX
       @scrollY = window.scrollY
     super

      exitOnClick: true

      keydown: (event) =>
        window.scrollTo @scrollX, @scrollY if options.returnToViewport
        if event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey
          HUD.hide()
          @exit()
          new PostFindMode if findModeQueryHasResults
        else if event.keyCode == keyCodes.enter
          handleEnterForFindMode()
          @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
            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
          HUD.showFindMode rawQuery
        else if KeyboardUtils.isEscape event
          @exit()
          handleEscapeForFindMode()
          new PostFindMode if findModeQueryHasResults


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

