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-all navigation breaks after invalid regexp #765

Closed
Wilfred opened this issue Nov 10, 2016 · 2 comments
Closed

swiper-all navigation breaks after invalid regexp #765

Wilfred opened this issue Nov 10, 2016 · 2 comments

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Nov 10, 2016

Given a buffer with the following contents:

foo=[1,2,3]
foo=[4,5,6]

And the following ivy settings:

(setq ivy-re-builders-alist '((t . ivy--regex-ignore-order)))

M-x swiper-all RET foo=\[ breaks ivy. I cannot move between results in the minibuffer (e.g. by pressing C-n and C-p).

I get the following error in *Messages*:

Error in post-command-hook (ivy--exhibit): (invalid-regexp "Trailing backslash")

The problem seems to occur when I've typed foo=\ but haven't yet typed the [.

@abo-abo
Copy link
Owner

abo-abo commented Nov 10, 2016

Thanks for the report, I can reproduce it.

I never use ivy--regex-ignore-order and don't have too much time right now, so I would really appreciate a PR with a fix.

Here's what a volunteer can do:

  1. Eval this to see the error comes from a bad regex:

    (swiper-all-function "foo=")

  2. Eval this to see where the bad regex comes from:

    (ivy--regex-ignore-order "foo=")
    ;; =>
    ;; (("foo=" . t))

  3. Update ivy--regex-ignore-order to return "foo=\\\\" in this case.

  4. Add an ERT test for this to ivy-test.el.

Wilfred added a commit to Wilfred/swiper that referenced this issue Nov 11, 2016
The input from the user may not be a valid regexp. Even when a user
types a valid regexp, there may be points where the intermediate value
is not a valid regexp.

Fall back to a literal string match if the input is not a valid regexp.

Fixes abo-abo#765.
@Wilfred
Copy link
Contributor Author

Wilfred commented Nov 11, 2016

Thanks, that's really helpful. I've created a PR along the lines you described.

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