       @input.value
 
   # Return the background-page query corresponding to the current input state.  In other words, reinstate any
-  # custom search engine keyword which is currently stripped from the input.
+  # search engine keyword which is currently stripped from the input, and strip any selection.
   getInputValueAsQuery: ->
     (if @suppressedLeadingKeyword? then @suppressedLeadingKeyword + " " else "") + @getInputWithoutSelectionRange()
 

  hide: (@postHideCallback = null) ->
    UIComponentServer.postMessage "hide"
    @reset()

  onHidden: ->
    @postHideCallback?()

class BackgroundCompleter
  debug: true

  # The "name" is the background-page completer to connect to: "omni", "tabs", or "bookmarks".
  constructor: (@name) ->
    @port = chrome.runtime.connect name: "completions"
    @messageId = null
    @reset()

    @port.onMessage.addListener (msg) =>
