summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2021-06-12 14:16:35 -0400
committerAndrew Gallant <jamslam@gmail.com>2021-06-12 14:18:53 -0400
commitbc76a30c23317526441a76f99ff397f65acea607 (patch)
treebd8fccdedac9718026f49443c336b9a09de23614 /tests
parent5e81c60b35ce1481cdce5aa933b808faa71bc90e (diff)
regex: fix -w when regex can match empty string
This is a weird bug where our optimization for handling -w more quickly than we would otherwise failed. In particular, if the original regex can match the empty string, then our word boundary detection would produce invalid indices to the start the next search at. We "fix" it by simply bailing when the indices are known to be incorrect. This wasn't a problem in a previous release since ripgrep 13 tweaked how word boundaries are detected in commit efd9cfb2. Fixes #1891
Diffstat (limited to 'tests')
-rw-r--r--tests/regression.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs
index c905e736..e35e953f 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -1029,3 +1029,11 @@ rgtest!(r1878, |dir: Dir, _: TestCommand| {
let args = &["-U", "--mmap", r"\Abaz", "test"];
dir.command().args(args).assert_err();
});
+
+// See: https://github.com/BurntSushi/ripgrep/issues/1891
+rgtest!(r1891, |dir: Dir, mut cmd: TestCommand| {
+ dir.create("test", "\n##\n");
+ // N.B. We use -o here to force the issue to occur, which seems to only
+ // happen when each match needs to be detected.
+ eqnice!("1:\n2:\n2:\n", cmd.args(&["-won", "", "test"]).stdout());
+});