       return row
     null
 
+  getRowForSelectedItem: ->
+    @getRowForItem(@getSelectedItem())
+
+  getRowForItem: (item) ->
+    @items.indexOf(item)
+
+  selectItem: (item) ->
+    row = @items.indexOf(item)
+    if row >= 0
+      @selectItemForRow(row)
+
   selectItemForRow: (row) ->
     item = @items[row]
     if item? and @isValidItem(item)


    @registerCommands()
    @observeInputChange()
    @observeCursorPositionChange()

  # Return row
  findValidItem: (startRow, direction) ->

    @items = [{_prompt: true, skip: true}, items...]
    text = (@provider.viewForItem(item) for item in items).join("\n")
    @appendText(text)

    if @provider.editor? and item = @findNearestItem(items)
      @selectItem(item)
    else
      @selectItemForRow(@findValidItem(1, 'next'))
