-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
--max-count has precedence over --after-context and --context #402
Copy link
Copy link
Closed
Labels
bugA bug.A bug.libripgrepAn issue related to modularizing ripgrep into libraries.An issue related to modularizing ripgrep into libraries.
Milestone
Description
I think --after-context (-A) and --context (-C) should have the same precedence as --before-context (-B), when being combined with --max-count (-m), but they do not:
$ cat > rgtest.txt <<EOF
> a
> b
> c
> d
> e
> EOF
$ rg -B2 c rgtest.txt
1-a
2-b
3:c
$ rg -C2 c rgtest.txt
1-a
2-b
3:c
4-d
5-e
$ rg -A2 c rgtest.txt
3:c
4-d
5-e
$ # and now with --max-count:
$ rg -B2 c -m1 rgtest.txt
1-a
2-b
3:c
$ rg -C2 c -m1 rgtest.txt
1-a
2-b
3:c
$ rg -A2 c -m1 rgtest.txt
3:cFrom my expectations, -B works correctly, -C works like -B which is unexpected, and -A has no effect at all.
My use case is to show a colleague one instance of many repeated matches, but also with some context. If -A combined with -m would yield the same result as with -B, then my use case would have been fulfilled.
I am using ripgrep-0.3.2-1.fc24.x86_64, packaged for Fedora through copr (by carlgeorge-ripgrep).
Thanks for a great program! (edit: removed trailing whitespace in code block)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugA bug.A bug.libripgrepAn issue related to modularizing ripgrep into libraries.An issue related to modularizing ripgrep into libraries.