atom / fuzzy-finder

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

prevent current editor from showing up first #349

Closed jacekkopecky closed 6 years ago

jacekkopecky commented 6 years ago

Requirements

Description of the Change

The current open editor can end up being the first result in fuzzy search. This change makes sure it isn't.

I have a project with HTML and JS files named the same but the file extension, e.g. project-marking.html and project-marking.js, and I often want to quickly open the other one using fuzzy finder. However, fuzzy finder puts the .js file first, so if I'm there, open fuzzy finder, type projmar, pressing enter would just take me where I already am.

I would like to open fuzzy finder, type projmar, press enter, and be in the other file that I know matches.

This PR is a quick hack, an RFC really, that implements this change. Every time we filter, it checks that if we have more than one match, the first one shouldn't be the current open buffer – if it is, it switches the first two matches.

Alternate Designs

I suspect that we might be able to cache the current open buffer's path when opening the fuzzy finder, but I don't know enough about the code to quickly guess where would be appropriate.

Also, this kind of sorting decision might be moved to fuzzaldrin, with some kind of value that shouldn't be put first parameter, but I don't have the time right now to investigate.

Benefits

This allows me quicker to change files with fuzzy finder.

Possible Drawbacks

If somebody already has in their muscle memory that they open fuzzy finder, type a query, and do down and enter, this would potentially give them the wrong file.

Applicable Issues

None I could find.

jacekkopecky commented 6 years ago

Sorry about the lint, I didn't notice standard.js was in use. The latest travis build failure seems to be something intermittent about the last few tests (not the one I added).

thomasjo commented 6 years ago

The latest travis build failure seems to be something intermittent about the last few tests (not the one I added).

Yeah, I restarted the build and it's :green_heart: now.

lee-dohm commented 6 years ago

Thanks very much for the contribution.

Upon reviewing this change with the team, we've decided that this poses too many risks with regard to people's established workflows. We can recommend that this could be useful as a community package that is more custom-built for this proposed workflow. Because of this, we're going to close the PR.

Thanks again for your hard work and interest in Atom :+1:

jacekkopecky commented 6 years ago

No worries.

🎉 welcome new Atom package: fuzzy-finder-switch-first