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

swiper-isearch doesn't work with ivy-restrict-to-matches #2168

Open
muirdm opened this issue Jul 24, 2019 · 2 comments
Open

swiper-isearch doesn't work with ivy-restrict-to-matches #2168

muirdm opened this issue Jul 24, 2019 · 2 comments

Comments

@muirdm
Copy link
Contributor

@muirdm muirdm commented Jul 24, 2019

When I run "ivy-restrict-to-matches" it seems to completely reset the search rather than limit to current matches.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 26, 2019

ivy-restrict-to-matches only works for static collections. Would be nice to extend it.

Two ways of going about it:

  1. Implement a mechanism that allows us to change a dynamic collection into a static one.
  2. Try to re-use ivy--regex-ignore-order and just keep stacking regexes on top of one another.

The second way is sub-optimal, since it's not generic: it wouldn't work for other dynamic collections and ivy--regex-fuzzy.

Although I have to admit that I haven't used ivy-restrict-to-matches in a few years. Thanks for reminding me it exists :)

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jul 26, 2019

I went with the first idea. Now ivy-restrict-to-matches works for things like counsel-rg.

But still doesn't work for swiper-isearch. The reason is this code:

(ivy--filter ivy-text ivy--all-candidates)

Usually, ivy--all-candidates is a list of strings, and ivy--filter knows how to filter those.

But for swiper-isearch, for performance purposes, ivy--all-candidates is a list of points. So then we need to either extend ivy-read with a way to customize :filter, or maybe hack swiper-isearch candidates to become strings.

The first is preferable, maybe we can leverage that to gain better performance. Right now, for each new input, we search through the whole buffer once more. But with :filter, we could for each candidate:

  • goto position
  • search until end of line to see if it matches

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

No branches or pull requests

2 participants