mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-07-26 01:31:57 -07:00
Fix another bug in -o/--only-matching.
The handling of the -o/--only-matching was incorrect. We cannot ever re-run regexes on a *subset* of a matched line, because it doesn't take into account zero width assertions on the edges of the regex. This occurs whenever an end user uses an assertion explicity, but also occurs when one is used implicitly, e.g., with the `-w` flag. This instead reuses the initial matched range from the first regex match. We also apply this fix to coloring. Fixes #493
This commit is contained in:
@@ -1079,7 +1079,8 @@ clean!(regression_428_color_context_path, "foo", ".", |wd: WorkDir, mut cmd: Com
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/428
|
||||
clean!(regression_428_unrecognized_style, "Sherlok", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
clean!(regression_428_unrecognized_style, "Sherlok", ".",
|
||||
|wd: WorkDir, mut cmd: Command| {
|
||||
cmd.arg("--colors=match:style:");
|
||||
wd.assert_err(&mut cmd);
|
||||
|
||||
@@ -1091,6 +1092,15 @@ Unrecognized style attribute ''. Choose from: nobold, bold, nointense, intense.
|
||||
assert_eq!(err, expected);
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/493
|
||||
clean!(regression_493, " 're ", "input.txt", |wd: WorkDir, mut cmd: Command| {
|
||||
wd.create("input.txt", "peshwaship 're seminomata");
|
||||
cmd.arg("-o").arg("-w");
|
||||
|
||||
let lines: String = wd.stdout(&mut cmd);
|
||||
assert_eq!(lines, " 're \n");
|
||||
});
|
||||
|
||||
// See: https://github.com/BurntSushi/ripgrep/issues/1
|
||||
clean!(feature_1_sjis, "Шерлок Холмс", ".", |wd: WorkDir, mut cmd: Command| {
|
||||
let sherlock =
|
||||
|
Reference in New Issue
Block a user