Repository navigation
fix(rg): sort metadata across explicit paths - #1958
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes rg metadata-based sorting (--sort / --sortr) so it applies consistently across all file candidates, including explicit file arguments and the --files explicit-path branch, matching ripgrep’s behavior more closely.
Changes:
- Represent explicit file arguments as
RgFileCandidate(with metadata) so they can be globally sorted together with recursively discovered files. - Add
display_override+explicittoRgFileCandidateand centralize display formatting incandidate_display_path(...)to preserve explicit-path display semantics. - Add differential test cases covering metadata sorting across explicit file arguments and
--files --sort modifiedwith explicit files.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 67638f3 | Commit Preview URL | Jun 05 2026, 08:28 PM |
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
--sort/--sortrmodes were only applied to recursive candidate batches, so explicit file/argument paths and the--filesexplicit-path branch were not ordered by metadata as intended.Description
RgFileCandidateentries (preserving metadata) instead of appending bare explicit inputs, so they can participate in a single global candidate sort.display_overrideandexplicitfields toRgFileCandidateand centralize display logic viacandidate_display_path(...)to preserve explicit-file display semantics.sort_rg_candidates(...)over the aggregated candidate list (honoring--sort/--sortrand--sort none) before reading files, and update--filesto render sorted candidate displays via the same helper.--files --sort modifiedwith explicit files.crates/bashkit/src/builtins/rg/mod.rsand aim to be minimal while preserving existing explicit-file behavior (binary handling, display formatting).Testing
cargo fmt --checkandcargo fmtto normalize formatting; check passed.cargo test -p bashkit builtins::rg::tests::diff_rg_matches_real_rg_casesand the suite passed.cargo test -p bashkit builtins::rg::tests::real_rg_binary_is_available_for_differential_testsand it passed.Codex Task