-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Searching with inline regex backreference only searches open files #27802
Comments
Seems to work if I turn set |
That's right, some regex features like backreferences and lookaround are not supported by ripgrep. |
I've seen several issues related to this, so maybe I should add a blurb in the docs? |
Thanks. Is there any potential problem with disabling Ripgrep (other than performance)? |
The only real problem I can see when Ripgrep is active is that it does find matches in open files (I'm not entirely sure how that works around the limitation of Ripgrep though), which can lead you to the mistaken assumption that you've found everything you were looking for. |
No, if you really need those features, you can disable ripgrep and just get a perf hit. Search in open files is done by the editor, so the JS features work there. And ripgrep doesn't complain when we use an unsupported feature so it's hard to know that there may be other matches. Trying to detect unsupported patterns in the input regex makes me nervous but it may be worth it to avoid confusion. The only reason I can think of that using ripgrep to search open files would be difficult is that it's really easy for the editor to do a search in a large file with unsaved changes, but slower to pipe all that text through ripgrep. |
Actually we do get an error when you try to use lookaround, which is good. Really it should raise an error for backreferences, but this issue: BurntSushi/ripgrep#268 - I think it would actually be fair for us to say, if the query contains |
@roblourens I think ripgrep should fix this. It won't happen right away so you may still want to create a work around (i.e., just outright reject octal escapes). More details: BurntSushi/ripgrep#268 (comment) |
Verifier - check that there is a warning printed when using a backreference like |
…. Ripgrep interprets this as an octal escape sequence, instead of a backreference.
As far as I can tell, finding in files with a regular expression including a backreference (e.g.
\1
) will only return results from files that are open. This may be by design or due to some limitation I'm not aware of, but I couldn't find anything in the docs.Steps to Reproduce:
(A).*?\1
. There are no results.The text was updated successfully, but these errors were encountered: