Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly use flx-make-filename-cache rather than flx-make-string-cache #2816

Open
marcsaegesser opened this issue Feb 26, 2021 · 1 comment · May be fixed by #2817
Open

Possibly use flx-make-filename-cache rather than flx-make-string-cache #2816

marcsaegesser opened this issue Feb 26, 2021 · 1 comment · May be fixed by #2817

Comments

@marcsaegesser
Copy link

I'm coming to ivy from flx-ido and found that filename matching was very different and less useful. I finally discovered the reason for the difference. When calling flx-score, flx-ido uses flx-file-cache, which is a filename cache defined in flx-ido.el. In ivy, the call to flx-score uses ivy--flx-cache which is a string cache defined in ivy.el. The difference in behavior is pretty big. Changing ivy--flx-cache to a filename cache would probably be too disruptive to people already familiar with the existing behavior. Maybe it would be possible add an official way to switch to using a filename cache rather than a string cache? In my current configuration I include (setq ivy--flx-cache (flx-make-filename-cache)) after ivy is loaded and the flex matching now works like I'm used to.

Here's an example of how matching is different. I have an sbt project with a source named something like "src/main/scala/org/fu/MySuperApp.scala". With a query of "ms" the string cache settles on the 'm' in main and the 's' in scala so all of my source code ends up with the same flx-score. The filename cache selects the 'M' and 'S' in the file name, which is a much more useful result.

basil-conto added a commit to basil-conto/swiper that referenced this issue Feb 27, 2021
* ivy.el: Avoid registering eval-after-load hooks or unconditionally
loading flx at load time.
(ivy--flx-featurep): Turn variable into "thunk" function that only
tries loading flx once when actually needed.  All uses changed.
(ivy-flx-cache): New escape hatch variable affording users control
over the default flx cache used.
(ivy--flx-cache): Turn variable into function that chooses between
types of flx cache subject to ivy--completing-fname-p and
ivy-flx-cache.  All uses changed.
(ivy-flx-limit): Improve docstring style.
(ivy-toggle-fuzzy): Quote function symbols as such.

Fixes abo-abo#2816.
@basil-conto basil-conto linked a pull request Feb 27, 2021 that will close this issue
@basil-conto
Copy link
Collaborator

I've never used flx or ivy--regex-fuzzy, so could you please check whether #2817 is even remotely close to doing the right thing? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants