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

New option: Stop on non-match after a match #1930

Closed

Conversation

edoardopirovano
Copy link
Contributor

Closes #1790

This implements the option suggested in the linked issue. In particular, it adds a --stop-on-nonmatch flag that will stop reading a file once a non-matching line is found after a matching one. This is useful if, for example, a sorted file is being searched and the pattern being matched on is at the start of the line (so it is expected all matches will be adjacent).

@edoardopirovano
Copy link
Contributor Author

Hi @BurntSushi! No particular rush, but just checking you've seen this PR? Let me know if there's any changes you'd like me to make 🙂

@BurntSushi
Copy link
Owner

No, I haven't looked at it yet. Unfortunately, my time is very limited and I tend to do PR reviews in batches in order to minimize context switching. It might be a while.

@@ -319,6 +319,7 @@ _rg() {
'(-q --quiet)'{-q,--quiet}'[suppress normal output]'
'--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)'
'*'{-u,--unrestricted}'[reduce level of "smart" searching]'
'--stop-on-nonmatch[stop on first non-matching line after a matching one]'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this missing the = sign like the rest of them?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The = sign is only used for flags that accept an argument.

@BurntSushi BurntSushi added the rollup A PR that has been merged with many others in a rollup. label Jul 8, 2023
BurntSushi pushed a commit that referenced this pull request Jul 8, 2023
This causes ripgrep to stop searching an individual file after it has
found a non-matching line. But this only occurs after it has found a
matching line.

Fixes #1790, Closes #1930
BurntSushi pushed a commit that referenced this pull request Jul 8, 2023
This causes ripgrep to stop searching an individual file after it has
found a non-matching line. But this only occurs after it has found a
matching line.

Fixes #1790, Closes #1930
BurntSushi pushed a commit that referenced this pull request Jul 8, 2023
This causes ripgrep to stop searching an individual file after it has
found a non-matching line. But this only occurs after it has found a
matching line.

Fixes #1790, Closes #1930
@BurntSushi BurntSushi closed this in 6d95c13 Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR that has been merged with many others in a rollup.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop on first non-match after positive match
3 participants