-
-
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
Fix reiteration of the first found match with --only-mathing flag #454
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix! I think this mostly looks good, but I left some nits on the test. I also think we should include a regression test that roughly matches what the reporter initially presented.
tests/tests.rs
Outdated
wd.create(path, "1 2 3\n123\n"); | ||
|
||
let mut cmd = wd.command(); | ||
cmd.arg("\\d").arg(path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use a raw string literal for this? e.g., r"\d"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
tests/tests.rs
Outdated
let mut cmd = wd.command(); | ||
cmd.arg("\\d").arg(path) | ||
.arg("--only-matching") | ||
.arg("--color=never") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right
tests/tests.rs
Outdated
@@ -1607,6 +1607,32 @@ fn regression_391() { | |||
assert_eq!(lines, "bar.py\n"); | |||
} | |||
|
|||
// See: https://github.com/BurntSushi/ripgrep/issues/451 | |||
#[test] | |||
fn regression_451_only_matching() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test looks good. Could you add another test that approximately mimics the bug report in #451? e.g., Test that the actual results printed are correct instead of just column numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I see. Yep
8e83224
to
8539784
Compare
8539784
to
5854b69
Compare
Looks good, thank you! |
Fixes #451