Handle correctly similar results from multiple projects #383
Conversation
672144e
to
c08e006
Compare
c08e006
to
9d23d9a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I requested a few minor changes, but also noticed a pretty big issue that already existed prior to these changes, which is our use of fs.existsSync
on the main thread. Maybe we address that one in a follow-up PR?
|
||
if (fs.existsSync(absolutePath)) { | ||
return absolutePath | ||
if (fs.existsSync(absolutePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that we this existsSync
call wasn't introduced with this change, but I really think we should avoid performing synchronous I/O on the main thread. You never know how long the disk read is going to block for, especially on a network drive. One way to do this would be to retain the absolute path of the results returned from fuzzy-native
. I'm not familiar with its current API, so this may require changes to that module. I doubt they would be too difficult and I am happy to help out with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I briefly looked at using the async version but that would require changes to atom-select-list
since it currently expects the filterFn
function to be sync, and changing that was not trivial.
I think that what you mention is similar to the alternate design on the description: that can definitely be done and in general terms it would be a better solution, we just need to make sure that the additional payload that we're serializing in order to pass it to the native module does not regress the overall filtering performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I totally missed your comments in the alternate design section. Sorry about that. I think it's worth pursuing that route fairly soon.
lib/fuzzy-finder-view.js
Outdated
@@ -390,27 +390,32 @@ module.exports = class FuzzyFinderView { | |||
return {uri: filePath, filePath, label} | |||
} | |||
|
|||
getAbsolutePath (relativePath) { | |||
const directories = atom.project.getDirectories() | |||
parseResultsFromFuzzyNative (results) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is minor, but I think "parse" isn't really the right word here. Maybe convertFuzzyNativeResultsToViews
or something along those lines?
spec/fuzzy-finder-spec.js
Outdated
@@ -351,6 +360,44 @@ describe('FuzzyFinder', () => { | |||
|
|||
expect(Array.from(projectView.element.querySelectorAll('li')).filter(a => a.textContent.includes('child-file.txt')).length).toBe(1) | |||
}) | |||
|
|||
it('Return all the results if they have the same relative path across multiple root folders', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally prefer test descriptions to read like an english sentence when appended to "it":
it("returns all the results if..."
Requirements
Description of the Change
This PR fixes #382 by adding any root that contains a filter result to the list of final results.
Alternate Designs
We could change
fuzzy-native
to accept an object that contains both the full path of the result (or an id) + the string to use for the matcher (as the standard fuzzy matcher does), but that would require sending a much bigger object to the native side which could slowdown thing (plus the change would be bigger and affect other repos).Benefits
Fixes #382
Possible Drawbacks
None that I can think of.
Applicable Issues
#382