       else
         @selectedChoice = null
       @display()
-
-    # select the first choice with matching text
-    # I don't think we should use this...
-    # selectChoiceByText: (text) ->
-    #   if text? and text isnt ''
-    #     matches = @choices.filter (choice) -> `choice.text == text`
-    #     if matches[0]?
-    #       @selectedChoice = matches[0]
-    #       @display()
-    #     else
-    #       @selectedChoice = matches[0]
-    #       @display()
 
     # return array of choices
     getChoices: ->

          @positionResultsArea()

    positionResultsArea: ->
      # TODO make this detect screen edge; go up if at bottom
      offset = @element.offset()
      height = @element.outerHeight()
      width = @element.outerWidth() - 2 # TODO make this more robust by detecting border widths and such
      @queryResultArea.css top: offset.top + height, left: offset.left, width: width

    highlightNextChoice: ->
      highlightedChoice = @queryResultArea.find('li.choice.active')
      if highlightedChoice.length is 1
        nextChoice = highlightedChoice.next('li.choice')
        if nextChoice.length is 1
          highlightedChoice.removeClass 'active'
          nextChoice.addClass 'active'

    highlightPreviousChoice: ->
      highlightedChoice = @queryResultArea.find('li.choice.active')
      if highlightedChoice.length is 1
        previousChoice = highlightedChoice.prev('li.choice')
        if previousChoice.length is 1
          highlightedChoice.removeClass 'active'
          previousChoice.addClass 'active'

    selectHighlightedChoice: ->
      highlightedChoice = @queryResultArea.find('li.choice.active')
      if highlightedChoice.length is 1
        value = highlightedChoice.data 'value'
        @selectChoiceByValue value
        @_val = @element.val()

              ''
            @queryResultArea.html "<ul>#{results.join '\n'}</ul>#{info}"
            @queryResultArea.find('li.choice:first').addClass 'active'
            @showResults()

      @element.on 'keydown', (e) =>
        if @queryResultArea.is(':visible')
