From f0976d4650cbf3f998baca2e2a68f01b778b561e Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Tue, 3 Jan 2012 17:06:58 -0800 Subject: [PATCH 1/2] FileFinder requires the full filePath. --- spec/atom/root-view-spec.coffee | 5 ----- src/atom/root-view.coffee | 1 - 2 files changed, 6 deletions(-) diff --git a/spec/atom/root-view-spec.coffee b/spec/atom/root-view-spec.coffee index 8c32a604a..2ac3e78c9 100644 --- a/spec/atom/root-view-spec.coffee +++ b/spec/atom/root-view-spec.coffee @@ -30,11 +30,6 @@ describe "RootView", -> rootView.toggleFileFinder() expect(rootView.fileFinder.urlList.children('li').length).toBe 3 - it "remove common path prefix from files", -> - rootView.toggleFileFinder() - commonPathPattern = new RegExp("^" + fs.directory(baseUrl)) - expect(rootView.fileFinder.urlList.children('li:first').text()).not.toMatch commonPathPattern - describe "when the editor has no url", -> it "does not open the FileFinder", -> expect(rootView.editor.buffer.url).toBeUndefined() diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index ba6581388..0af4da34c 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -39,7 +39,6 @@ class RootView extends Template else directory = fs.directory @editor.buffer.url urls = (url for url in fs.list(directory, true) when fs.isFile url) - urls = (url.replace(directory, "") for url in urls) @fileFinder = FileFinder.build({urls}) @addPane(@fileFinder) @fileFinder.input.focus() From 44802e9647060cc96533817f7c2c1365641c5cdc Mon Sep 17 00:00:00 2001 From: Corey Johnson & Nathan Sobo Date: Tue, 3 Jan 2012 17:07:24 -0800 Subject: [PATCH 2/2] Hitting enter on FileFinder opens file in new window. --- spec/atom/file-finder-spec.coffee | 14 ++++++++++++++ src/atom/file-finder.coffee | 6 ++++++ 2 files changed, 20 insertions(+) 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)')