diff --git a/spec/atom/file-finder-spec.coffee b/spec/atom/file-finder-spec.coffee index a22bf4dba..1faf3181f 100644 --- a/spec/atom/file-finder-spec.coffee +++ b/spec/atom/file-finder-spec.coffee @@ -58,6 +58,20 @@ describe 'FileFinder', -> expect(finder.find('li:last')).toHaveClass "selected" + describe "select", -> + it "when an file is selected atom.open is called", -> + spyOn(atom, 'open') + finder.moveDown() + finder.select() + expect(atom.open).toHaveBeenCalledWith(urls[1]) + + it "when no file is selected, does nothing", -> + spyOn(atom, 'open') + finder.input.val('this-will-match-nothing-hopefully') + finder.populateUrlList() + finder.select() + expect(atom.open).not.toHaveBeenCalled() + describe "findMatches(queryString)", -> it "returns up to finder.maxResults urls if queryString is empty", -> expect(urls.length).toBeLessThan finder.maxResults diff --git a/src/atom/file-finder.coffee b/src/atom/file-finder.coffee index 93706fb9a..4d3a4c9dd 100644 --- a/src/atom/file-finder.coffee +++ b/src/atom/file-finder.coffee @@ -20,6 +20,7 @@ class FileFinder extends Template @populateUrlList() @bindKey 'up', 'moveUp' @bindKey 'down', 'moveDown' + @bindKey 'enter', 'select' populateUrlList: -> @urlList.empty() @@ -31,6 +32,11 @@ class FileFinder extends Template findSelectedLi: -> @urlList.children('li.selected') + select: -> + filePath = @findSelectedLi().text() + atom.open filePath if filePath + + moveUp: -> @findSelectedLi() .filter(':not(:first-child)') diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index 1c20dc7cc..e198fd174 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -46,4 +46,3 @@ class RootView extends Template @fileFinder = FileFinder.build({urls}) @addPane(@fileFinder) @fileFinder.input.focus() -