summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPen Tree <appletree2479@outlook.com>2020-07-11 18:42:54 +0800
committerAndrew Gallant <jamslam@gmail.com>2021-05-31 21:51:18 -0400
commit0ca96e004c539e44242607fee5c4661edf27a5cd (patch)
tree727da936a7399a26ffbd967843d676e2e94372e8 /tests
parent2295061e8079b146e656526ce1b264bf8f217585 (diff)
printer: fix context bug when --max-count is used
In the case where after-context is requested with a match count limit, we need to be careful not to reset the state tracking the remaining context lines. Fixes #1380, Closes #1642
Diffstat (limited to 'tests')
-rw-r--r--tests/regression.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/regression.rs b/tests/regression.rs
index 1bf239b8..8c132795 100644
--- a/tests/regression.rs
+++ b/tests/regression.rs
@@ -763,6 +763,28 @@ rgtest!(r1334_crazy_literals, |dir: Dir, mut cmd: TestCommand| {
);
});
+// See: https://github.com/BurntSushi/ripgrep/issues/1380
+rgtest!(r1380, |dir: Dir, mut cmd: TestCommand| {
+ dir.create(
+ "foo",
+ "\
+a
+b
+c
+d
+e
+d
+e
+d
+e
+d
+e
+",
+ );
+
+ eqnice!("d\ne\nd\n", cmd.args(&["-A2", "-m1", "d", "foo"]).stdout());
+});
+
// See: https://github.com/BurntSushi/ripgrep/issues/1389
rgtest!(r1389_bad_symlinks_no_biscuit, |dir: Dir, mut cmd: TestCommand| {
dir.create_dir("mydir");