atom / fuzzy-finder

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

Keep existing selection after reindexing #336

Open 50Wliu opened 6 years ago

50Wliu commented 6 years ago

Requirements

Description of the Change

After a reindex completes, all the items in the select list get regenerated. If someone had a file selected, the refresh would cause the selection to jump back to the first element. This PR fixes that by manually re-selecting the previous file after the reindex completes.

Alternate Designs

I hope there's an alternate design; this one didn't come out that pretty.

Benefits

Selection will not unexpectedly change after a reindex completes.

Possible Drawbacks

The for loop I added creates some delay, especially for larger projects since it loops through every single file.

Applicable Issues

Fixes #210

/cc @Ben3eeE

Ben3eeE commented 6 years ago

@50Wliu Thanks for opening this ⚡️ LGTM. I couldn't notice any delay even with a larger project and slow computer where I noticed the issue this fixes!

🚢 if you are fine with the drawback!

nfarina commented 6 years ago

This issue has been driving me crazy - would love to have this fixed! Any reason it can't be merged? Seems like a slam dunk—straightforward code and small scope of changes.

50Wliu commented 6 years ago

Forgot about this PR. Let me revisit it in the next few days and see if I can remember my logic here.