atom / fuzzy-finder

Find and open files quickly
MIT License
274 stars 138 forks source link

Eliminate synchronous I/O on main thread when displaying match results from fuzzy-native #384

Closed nathansobo closed 5 years ago

nathansobo commented 5 years ago

🍐'd with @rafeca

Description of the Change

Previously, limitations in the fuzzy-native API required us to call fs.existsSync on the main thread in order to map the relative paths in match results back into absolute paths in the presence of multiple project roots. This could block the main thread for an arbitrary amount of time and lead to performance degradation, so we decided to fix it.

The fix involved changing fuzzy-native's API to associate each match candidate with an integer identifier. Currently, we're just assigning each item's id to its index in the items array. Now, when we get a match back from fuzzy-native, we can map it back to the original item that produced the candidate via the match's id. This removes the need for synchronous I/O to disambiguate the relative path.

Alternate Designs

I'd love to replace fuzzy-native entirely, but that's out of scope right now.

Benefits

Possible Drawbacks

Applicable Issues

383

382

https://github.com/atom/fuzzy-native/pull/3