From df1f176fea3148dbaf41bf2a949be4306a0350dc Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Wed, 13 Jul 2016 23:24:00 +0200 Subject: [PATCH 1/5] Add match for exact path ref #158 --- lib/fuzzy-finder-view.coffee | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/fuzzy-finder-view.coffee b/lib/fuzzy-finder-view.coffee index e569b412..c257f00f 100644 --- a/lib/fuzzy-finder-view.coffee +++ b/lib/fuzzy-finder-view.coffee @@ -175,6 +175,9 @@ class FuzzyFinderView extends SelectListView else filteredItems = @items + if fs.isFileSync filterQuery + filteredItems.push(filePath: filterQuery, projectRelativePath: filterQuery) + @list.empty() if filteredItems.length @setError(null) From 9cac98e40d0b150cae27322ddbcdebf76cee39fb Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Fri, 15 Jul 2016 22:44:33 +0200 Subject: [PATCH 2/5] test: add some specs for the full path match --- spec/fuzzy-finder-spec.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/fuzzy-finder-spec.coffee b/spec/fuzzy-finder-spec.coffee index cef500ee..e1dcc29e 100644 --- a/spec/fuzzy-finder-spec.coffee +++ b/spec/fuzzy-finder-spec.coffee @@ -585,6 +585,20 @@ describe 'FuzzyFinder', -> expect(atom.workspace.panelForItem(projectView).isVisible()).toBe false expect(inputView).toHaveFocus() + describe "when the filter text contains an absolute path", -> + it "it matches the given path", -> + dispatchCommand('toggle-file-finder') + expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true + expectedPath = path.join(rootDir2, "sample.html") + + projectView.filterEditorView.getModel().insertText(expectedPath) + projectView.populateList() + waitForPathsToDisplay projectView + + runs -> + {filePath} = projectView.getSelectedItem() + expect(atom.project.getDirectories()[0].resolve(filePath)).toBe expectedPath + describe "cached file paths", -> beforeEach -> spyOn(PathLoader, "startTask").andCallThrough() From 815abd591849e1edb251200576a5ac568ae9af08 Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Fri, 15 Jul 2016 23:36:04 +0200 Subject: [PATCH 3/5] feat: add normalization of the path --- lib/fuzzy-finder-view.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fuzzy-finder-view.coffee b/lib/fuzzy-finder-view.coffee index c257f00f..af639055 100644 --- a/lib/fuzzy-finder-view.coffee +++ b/lib/fuzzy-finder-view.coffee @@ -175,8 +175,9 @@ class FuzzyFinderView extends SelectListView else filteredItems = @items - if fs.isFileSync filterQuery - filteredItems.push(filePath: filterQuery, projectRelativePath: filterQuery) + normalizedQuery = fs.normalize(filterQuery) + if fs.isFileSync(normalizedQuery) + filteredItems.push(filePath: normalizedQuery, projectRelativePath: normalizedQuery) @list.empty() if filteredItems.length From 7bbb46c4a8fbf28a2cf4d4858bdbee3891fbda80 Mon Sep 17 00:00:00 2001 From: eMerzh Date: Sat, 16 Jul 2016 08:35:49 +0200 Subject: [PATCH 4/5] remove duplicated it --- spec/fuzzy-finder-spec.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/fuzzy-finder-spec.coffee b/spec/fuzzy-finder-spec.coffee index e1dcc29e..89c2c707 100644 --- a/spec/fuzzy-finder-spec.coffee +++ b/spec/fuzzy-finder-spec.coffee @@ -586,7 +586,7 @@ describe 'FuzzyFinder', -> expect(inputView).toHaveFocus() describe "when the filter text contains an absolute path", -> - it "it matches the given path", -> + it "matches the given path", -> dispatchCommand('toggle-file-finder') expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true expectedPath = path.join(rootDir2, "sample.html") From db78c6d5e56e48057b6c6230c0e6edcca1e696dd Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Sun, 17 Jul 2016 14:04:29 +0200 Subject: [PATCH 5/5] test: add test for normalization --- spec/fuzzy-finder-spec.coffee | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/fuzzy-finder-spec.coffee b/spec/fuzzy-finder-spec.coffee index 89c2c707..9d8a110d 100644 --- a/spec/fuzzy-finder-spec.coffee +++ b/spec/fuzzy-finder-spec.coffee @@ -599,6 +599,20 @@ describe 'FuzzyFinder', -> {filePath} = projectView.getSelectedItem() expect(atom.project.getDirectories()[0].resolve(filePath)).toBe expectedPath + it "accepts not normalized path", -> + dispatchCommand('toggle-file-finder') + expect(atom.workspace.panelForItem(projectView).isVisible()).toBe true + expectedPath = path.join(rootDir2, "sample.html") + searched = path.join(rootDir2, "..", "sample.html") + + projectView.filterEditorView.getModel().insertText(expectedPath) + projectView.populateList() + waitForPathsToDisplay projectView + + runs -> + {filePath} = projectView.getSelectedItem() + expect(atom.project.getDirectories()[0].resolve(filePath)).toBe expectedPath + describe "cached file paths", -> beforeEach -> spyOn(PathLoader, "startTask").andCallThrough()