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

counsel-ag not narrowing results #1907

Closed
paulbdavis opened this issue Jan 28, 2019 · 11 comments
Closed

counsel-ag not narrowing results #1907

paulbdavis opened this issue Jan 28, 2019 · 11 comments

Comments

@paulbdavis
Copy link

@paulbdavis paulbdavis commented Jan 28, 2019

Using counsel-ag in version 0.11.0 does not narrow any results. No matter the search string I enter, all of the lines in the directory show up in search. Before the update to 0.11.0 it worked fine.

Using counsel-git-grep does narrow as expected and just running ag returns a buffer with the matching lines as expected.

EDIT: tried to add a screenshot, but the button to do that seems to be gone... (how do I drag without a file manager Microsoft!?!)

EDIT2: Oh, you click the text... nice UI design..

Here is the screenshot

counsel-bug

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

Can't reproduce on GNU/Linux and Emacs 26.1. I assume you're on Windows. What's your ag --version?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

Also, what's your setting of counsel-ag-base-command. And what does e.g. "ag --vimgrep ivy" produce from M-x shell?

@paulbdavis
Copy link
Author

@paulbdavis paulbdavis commented Jan 29, 2019

I am on GNU/Linux (Arch) and Emacs 26.1.

$ ag --version
ag version 2.2.0

Features:
  +jit +lzma +zlib

counsel-ag-base-command is set to "ag --nocolor --nogroup %s"

Running the ag command you mentioned in M-x shell produces the expected results

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

I have ag 2.1.0, but I don't think that should matter. Can you reproduce by cloning this repo and running make plain and M-x counsel-ag?

@paulbdavis
Copy link
Author

@paulbdavis paulbdavis commented Jan 29, 2019

Upon further investigation, it seems that setting (setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)) is the cause of the issue. Setting it back to ivy--regex-plus fixes it. I had this setting on the previous version and it did not break counsel-ag

@paulbdavis
Copy link
Author

@paulbdavis paulbdavis commented Jan 29, 2019

  (setq ivy-re-builders-alist '((counsel-ag . ivy--regex-plus)
                                (t . ivy--regex-fuzzy)))

Using these settings seems to fix it while keeping fuzzy matching everywhere else

@abo-abo abo-abo closed this in 08dd58b Jan 29, 2019
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

Thanks. The recent improvements to ivy--regex-fuzzy and ag's interpretation of what "[^a]" should match resulted in this bug. It should be fixed now, you can now use ivy--regex-fuzzy for ag once more.

This problem doesn't happen with ripgrep, because it thinks (and I agree) that "[^a]" should not match a newline. See the commit message for details.

@paulbdavis
Copy link
Author

@paulbdavis paulbdavis commented Jan 29, 2019

any chance it will get tagged as 0.11.1? I am trying to keep as many of my packages on stable versions as possible

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

I'll try to tag 0.11.1 later. Thing is, the "fix" could potentially backfire somewhere else. I don't want to tag commits that are minutes old.

@paulbdavis
Copy link
Author

@paulbdavis paulbdavis commented Jan 29, 2019

Fair enough. Thanks again for all of the work you do

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Jan 29, 2019

You're welcome.

flexyford added a commit to thefrontside/frontmacs that referenced this issue May 10, 2019
A bug in swiper is causing counsel-ag to not narrow any results using
fuzzy search. This will be fixed in an upcoming release of swiper.

abo-abo/swiper#1907
astoff added a commit to astoff/swiper that referenced this issue Jan 1, 2021
ag (the Silver Searcher) suffers from this:

    ag --nocolor --nogroup  \(b\)[^a]*\(a\)[^c]*\(c\)[^k]*\(k\)

This will produce way too many matches, because e.g. ag thinks [^a]
should also match newlines, which means that we can get "b" on one
line, "a" on the second and so on.

* ivy-test.el (ivy--regex-fuzzy): Update test.

Fixes abo-abo#1907
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants