fix(rg): apply max-count after multiline invert#1752
Merged
chaliy merged 1 commit intoMay 25, 2026
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 842647e | Commit Preview URL | May 25 2026, 04:31 PM |
Multiline --invert-match was passing opts.max_count into positive-span collection, truncating positive spans before inversion and producing too much inverted output. Match ripgrep: collect all positive spans, then apply -m/--max-count to the inverted result. Rebased on current main; original PR #1752 by chaliy.
39160da to
842647e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
--invert-matchwas passingopts.max_countinto positive-span collection, truncating positive spans before inversion and producing too much inverted output.-m/--max-countto the inverted result.Description
crates/bashkit/src/builtins/rg/mod.rscallcollect_rg_multiline_matcheswithNonewhenopts.invert_matchso positive spans are fully collected instead of truncated byopts.max_count.inverted_match_lines, applyopts.max_countby truncating the vector to enforce the max-count limit on inverted output.test_rg_multiline_invert_max_countincrates/bashkit/src/builtins/rg/mod.rsthat verifies-m 1 -v -U 'foo\nbar'returns only the first inverted line.Testing
test_rg_multiline_invert_max_countwhich reproduces the reported regression and asserts expected output.cargo test -p bashkit test_rg_multiline_invert_max_count -- --nocaptureand the test passed (1 passed; 0 failed).Codex Task