-
-
Notifications
You must be signed in to change notification settings - Fork 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
Feature idea: "context matches" #346
Comments
I'm not against this on principle, but it would be a very difficult feature to add in the current implementation. |
Ah, that makes sense. I was hoping that it would be as simple as just caching the output for each chunk for a bit and running a regex over that cached chunk. |
Which is obviously less efficient than some kind of fancy one-pass analysis. |
related to: #360 |
The current implementation already does that. It has to, because it doesn't know which lines to print until a match occurs. You're welcome to go look at the code and marvel at just how hard an addition like this would be. The context handling is complicated, which is why I've tagged this with |
Hello, It might sound stupid, but what would be the difference between:
and:
|
ripgrep doesn't do multiline search.
…On Mar 3, 2017 3:29 AM, "Ivan Enderlin" ***@***.***> wrote:
Hello,
It might sound stupid, but what would be the difference between:
$ rg --context-matches 'foo' 'bar'
and:
$ rg 'foo.*bar'
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#346 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAb34laVxe-2mr2JkmfV74h-QJmsWW2iks5rh893gaJpZM4L1XYf>
.
|
I'm going to close this not only because the implementation complexity of this scares me a little, but it opens the door to a whole new world of feature bloat that I'd rather avoid. I'd kindly suggest that if someone wants a search this sophisticated, they should just write some code or figure out a clever work-around using the existing context flags. :-) |
A related idea that might be much easier to implement: a context state match. Rather than printing lines before or after the match, a context match would print the most recent matching line of context, if any. Any given context match is only printed (once) when the main match hits. So with a file like:
and
|
I "often" find myself doing something like:
it would be kind of awesome if
rg
took a--context-matches
regex (that requires one of the other context specifiers (-A -B -C
)) that does this automatically for me.The text was updated successfully, but these errors were encountered: