   else if event.key == "ArrowUp"
     if rawQuery = FindModeHistory.getQuery findMode.historyIndex + 1
       findMode.historyIndex += 1
-      findMode.partialQuery = findMode.rawQuery if findMode.historyIndex == 0
+      if findMode.historyIndex == 0
+        findMode.partialQuery = findMode.rawQuery
       setTextInInputElement inputElement, rawQuery
       findMode.executeQuery()
   else if event.key == "ArrowDown"

  selection = window.getSelection()
  selection.removeAllRanges()
  selection.addRange range

document.addEventListener "DOMContentLoaded", ->
  DomUtils.injectUserCss() # Manually inject custom user styles.

    document.getElementById("hud").classList.add "vimiumUIComponentVisible"
    document.getElementById("hud").classList.remove "vimiumUIComponentHidden"
    document.getElementById("hud").classList.remove "hud-find"
    return
  hidden: ->
    # We get a flicker when the HUD later becomes visible again (with new text) unless we reset its contents
    # here.
    document.getElementById("hud").innerText = ""
    document.getElementById("hud").classList.add "vimiumUIComponentHidden"
    document.getElementById("hud").classList.remove "vimiumUIComponentVisible"
    return

  showFindMode: (data) ->
    hud = document.getElementById "hud"
