Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Add match for exact path ref #158 #237

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/fuzzy-finder-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ class FuzzyFinderView extends SelectListView
else
filteredItems = @items

normalizedQuery = fs.normalize(filterQuery)
if fs.isFileSync(normalizedQuery)
filteredItems.push(filePath: normalizedQuery, projectRelativePath: normalizedQuery)

@list.empty()
if filteredItems.length
@setError(null)
Expand Down
28 changes: 28 additions & 0 deletions spec/fuzzy-finder-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,34 @@ describe 'FuzzyFinder', ->
expect(atom.workspace.panelForItem(projectView).isVisible()).toBe false
expect(inputView).toHaveFocus()

describe "when the filter text contains an absolute path", ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that relative paths are supported, can you also add a test for that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not really relative.... it's "normalized" , you can't do like ../current_file.html
although it could be interesting

but you cant do
~/.atom/config.cson or /home/me/../hello

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

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()
Expand Down