-
Notifications
You must be signed in to change notification settings - Fork 27.9k
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
Regex search yields zero results when matches exist #50001
Comments
(Experimental duplicate detection) |
Do your files use CRLF line endings? Most likely #36309 (comment) |
Yes. Agreed. Is there a recommended workaround? This is a terrible experience for a frequent use case on Windows. |
I would go as far as to say that this is totally broken. The best case result is the user doesn't trust Code for regex searching and goes off and uses another tool (my case). And then eventually wastes their time and yours opening a dup issue. The worst case is they proceed on the understanding that a pattern doesn't match and never discover that it really does. |
And why is the find in files behavior different if a file is open (i.e. we get a match, step 11 above)? Completely non-intuitive. Cheap workaround is to insert |
Open files are searched in the editor model using the JS regex engine and there are a couple subtle differences between that and the Rust regex engine used by ripgrep, a tool that that search uses. I guess #36309 is "\s matches CR" and this is "$ doesn't match CR". This one we can actually work around automatically by replacing |
A separate issue could be that when invoking Find in Files, the output should be the same regardless of whether a file is open. I understand there is a different engine used by |
That would be ideal and I wish I could make it work, but if we want to support things like search finding matches in modified files, it's not practical. |
It still seems counterintuitive that |
It's really |
From my limited understanding, Windows uses CR+LF, or |
No problem at all. You are exactly right. But from ripgrep's perspective, If the regex doesn't have a match for that character, then the regex engine stops matching when it reaches |
Of course! Got it :) Thanks, Rob! |
(FWIW, adding support for CRLF line ending support is on my radar for future enhancements to Rust's regex engine, but it will be quite some time before it happens unfortunately.) |
Steps to Reproduce:
Ctrl+Shift+F
, turn on Use Regular Expression.^The.*?:$
$
and search again.3dprint\3d-manufacturing-keywords-overview.md
)$
at end of regex and search again.Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: