add complection for built-in --hyperlink-formats#3096
add complection for built-in --hyperlink-formats#3096ilyagr wants to merge 1 commit intoBurntSushi:masterfrom
--hyperlink-formats#3096Conversation
The goal is to make the completion for `rg --hyperlink-format v<TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). If this ever makes a difference, perhaps `fn doc_choices_are_exhaustive(&self) -> bool` can be added to the `Flags` trait. The `grep+` value necessitated a change to a test. I'm not sure whether there's a good way to generate the choices directly from `hyperlink_aliases.rs` as a `&'static [&'static str]`. The simplest would be to reorganize `hyperlink_aliases.rs` to keep the keys and values in separate arrays, but that would be less readable. OTOH, the values already need to be kept in sync with the long-form description inside the help text, which currently also has to be an &'static str.
62b8c05 to
4444c4e
Compare
--hyperlink-formats--hyperlink-formats
|
I like the idea of adding completion! But you don't need to duplicate the names: const ALIAS_COUNT: usize = HYPERLINK_PATTERN_ALIASES.len();
const ALIAS_NAMES: &[&str] = &{
let mut names = [""; ALIAS_COUNT];
let mut i = 0;
while i < ALIAS_COUNT {
names[i] = HYPERLINK_PATTERN_ALIASES[i].0;
i += 1;
}
names
};You can then return the required result type: fn alias_names() -> &'static [&'static str] {
ALIAS_NAMES
} |
|
Thanks, I was wondering if that's possible, glad to know the answer to the riddle! This diff seems to work: diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs
index 2d75a66a77..d8445c0a0f 100644
--- a/crates/core/flags/defs.rs
+++ b/crates/core/flags/defs.rs
@@ -2954,18 +2954,7 @@
}
fn doc_choices(&self) -> &'static [&'static str] {
- &[
- "default",
- "none",
- "file",
- "grep+",
- "kitty",
- "macvim",
- "textmate",
- "vscode",
- "vscode-insiders",
- "vscodium",
- ]
+ grep::printer::hyperlink_alias_names()
}
fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {
diff --git a/crates/printer/src/hyperlink_aliases.rs b/crates/printer/src/hyperlink_aliases.rs
index 9bad1b862d..c13db22c0d 100644
--- a/crates/printer/src/hyperlink_aliases.rs
+++ b/crates/printer/src/hyperlink_aliases.rs
@@ -21,6 +21,20 @@
("vscodium", "vscodium://file{path}:{line}:{column}"),
];
+const ALIAS_COUNT: usize = HYPERLINK_PATTERN_ALIASES.len();
+
+const HYPERLINK_FORMAT_ALIAS_NAMES: &[&str] = &{
+ let mut names = [""; ALIAS_COUNT];
+ let mut i = 0;
+
+ while i < ALIAS_COUNT {
+ names[i] = HYPERLINK_PATTERN_ALIASES[i].0;
+ i += 1;
+ }
+
+ names
+};
+
/// Look for the hyperlink format defined by the given alias name.
///
/// If one does not exist, `None` is returned.
@@ -31,6 +45,11 @@
.ok()
}
+/// List of pre-defined hyperlink format aliases
+pub fn hyperlink_alias_names() -> &'static [&'static str] {
+ HYPERLINK_FORMAT_ALIAS_NAMES
+}
+
/// Return an iterator over all available alias names and their definitions.
pub(crate) fn iter() -> impl Iterator<Item = (&'static str, &'static str)> {
HYPERLINK_PATTERN_ALIASES.iter().copied()
diff --git a/crates/printer/src/lib.rs b/crates/printer/src/lib.rs
index 5748862cb9..a046361bad 100644
--- a/crates/printer/src/lib.rs
+++ b/crates/printer/src/lib.rs
@@ -66,6 +66,7 @@
HyperlinkConfig, HyperlinkEnvironment, HyperlinkFormat,
HyperlinkFormatError,
},
+ hyperlink_aliases::hyperlink_alias_names,
path::{PathPrinter, PathPrinterBuilder},
standard::{Standard, StandardBuilder, StandardSink},
stats::Stats,I'm happy to merge this into the PR if the author thinks the duplication reduction is worth changing the The next puzzle (with an even less clear complexity trade-off) would be to generate the I found that there is the https://docs.rs/const_format/ crate, but I'm not sure whether ripgrep wants to depend on such things. |
I put it into
That would be really nice, but don't expect being allowed to add a crate for this. 😅 |
|
I'll save your commit for posterity below. I think I generally find your approach very much worth knowing about. But, as far as the PR goes, the main question in my mind is whether the complexity is worth it, considering that there will still be duplication with I think I'd like a maintainer to think about this for a second and decide. diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs
index 9a196c491..4c1c58c0e 100644
--- a/crates/core/flags/defs.rs
+++ b/crates/core/flags/defs.rs
@@ -2953,6 +2953,10 @@ https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
"#
}
+ fn doc_choices(&self) -> &'static [&'static str] {
+ grep::printer::HyperlinkFormat::alias_names()
+ }
+
fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {
let v = v.unwrap_value();
let string = convert::str(&v)?;
@@ -7665,9 +7669,10 @@ mod tests {
assert!(
choice.chars().all(|c| c.is_ascii_alphanumeric()
|| c == '-'
+ || c == '+'
|| c == ':'),
"choice '{choice}' for flag '{long}' does not match \
- ^[-:0-9A-Za-z]+$",
+ ^[-+:0-9A-Za-z]+$",
)
}
}
diff --git a/crates/printer/src/hyperlink.rs b/crates/printer/src/hyperlink.rs
index ec1fd9211..afa662634 100644
--- a/crates/printer/src/hyperlink.rs
+++ b/crates/printer/src/hyperlink.rs
@@ -90,6 +90,11 @@ impl HyperlinkFormat {
pub(crate) fn is_line_dependent(&self) -> bool {
self.is_line_dependent
}
+
+ /// List of predefined hyperlink format aliases
+ pub fn alias_names() -> &'static [&'static str] {
+ hyperlink_aliases::alias_names()
+ }
}
impl std::str::FromStr for HyperlinkFormat {
diff --git a/crates/printer/src/hyperlink_aliases.rs b/crates/printer/src/hyperlink_aliases.rs
index 9bad1b862..0dcf6a093 100644
--- a/crates/printer/src/hyperlink_aliases.rs
+++ b/crates/printer/src/hyperlink_aliases.rs
@@ -21,6 +21,20 @@ const HYPERLINK_PATTERN_ALIASES: &[(&str, &str)] = &[
("vscodium", "vscodium://file{path}:{line}:{column}"),
];
+const ALIAS_COUNT: usize = HYPERLINK_PATTERN_ALIASES.len();
+
+const ALIAS_NAMES: &[&str] = &{
+ let mut names = [""; ALIAS_COUNT];
+ let mut i = 0;
+
+ while i < ALIAS_COUNT {
+ names[i] = HYPERLINK_PATTERN_ALIASES[i].0;
+ i += 1;
+ }
+
+ names
+};
+
/// Look for the hyperlink format defined by the given alias name.
///
/// If one does not exist, `None` is returned.
@@ -36,6 +50,10 @@ pub(crate) fn iter() -> impl Iterator<Item = (&'static str, &'static str)> {
HYPERLINK_PATTERN_ALIASES.iter().copied()
}
+pub(crate) fn alias_names() -> &'static [&'static str] {
+ ALIAS_NAMES
+}
+
#[cfg(test)]
mod tests {
use crate::HyperlinkFormat; |
To be clear, if you (Lucas) feel like you understand this repo's style well enough to judge what's best for Update: I see you're responsible for ripgrep supporting hyperlinks in the first place, #2610. Thank you very much! |
The way I see it, I just added a
Absolutely not, I don't even see why you would think that.
You're welcome! 🙂 |
|
I played a bit with eliminating the duplication in I kept the code simple since the output of |
|
Does it work in stable Rust? I tried to adjust the code above accordintly, to const HYPERLINK_FORMAT_ALIAS_NAMES: &[&str] = &{
let mut names = [""; ALIAS_COUNT];
for (i, (name, _)) in HYPERLINK_PATTERN_ALIASES.iter().enumerate() {
names[i] = name;
}
names
};but I get: |
|
Ah, I see, you used Why is Could |
Actually |
The goal is to make the completion for `rg --hyperlink-format v<TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). This is somewhat unfortunate, but is probably better than not doing anything at all. The `grep+` value necessitated a change to a test. Closes #3096
The goal is to make the completion for `rg --hyperlink-format v<TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). This is somewhat unfortunate, but is probably better than not doing anything at all. The `grep+` value necessitated a change to a test. Closes #3096
The goal is to make the completion for `rg --hyperlink-format v<TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). This is somewhat unfortunate, but is probably better than not doing anything at all. The `grep+` value necessitated a change to a test. Closes #3096
The goal is to make the completion for `rg --hyperlink-format v<TAB>` work in the fish shell. These are not exhaustive (the user can also specify custom formats). This is somewhat unfortunate, but is probably better than not doing anything at all. The `grep+` value necessitated a change to a test. Closes #3096
|
Thank you! |
⚠️ **CAUTION: this is a major update, indicating a breaking change!**⚠️ This MR contains the following updates: | Package | Update | Change | |---|---|---| | [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) | major | `14.1.1` -> `15.0.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>BurntSushi/ripgrep (BurntSushi/ripgrep)</summary> ### [`v15.0.0`](https://github.com/BurntSushi/ripgrep/blob/HEAD/CHANGELOG.md#1500-2025-10-15) [Compare Source](BurntSushi/ripgrep@14.1.1...15.0.0) \=================== ripgrep 15 is a new major version release of ripgrep that mostly has bug fixes, some minor performance improvements and minor new features. Here are some highlights: - Several bugs around gitignore matching have been fixed. This includes a commonly reported bug related to applying gitignore rules from parent directories. - A memory usage regression when handling very large gitignore files has been fixed. - `rg -vf file`, where `file` is empty, now matches everything. - The `-r/--replace` flag now works with `--json`. - A subset of Jujutsu (`jj`) repositories are now treated as if they were git repositories. That is, ripgrep will respect `jj`'s gitignores. - Globs can now use nested curly braces. Platform support: - `aarch64` for Windows now has release artifacts. - `powerpc64` no longer has release artifacts generated for it. The CI release workflow stopped working, and I didn't deem it worth my time to debug it. If someone wants this and can test it, I'd be happy to add it back. - ripgrep binaries are now compiled with full LTO enabled. You may notice small performance improvements from this and a modest decrease in binary size. Performance improvements: - [PERF #​2111](BurntSushi/ripgrep#2111): Don't resolve helper binaries on Windows when `-z/--search-zip` isn't used. - [PERF #​2865](BurntSushi/ripgrep#2865): Avoid using path canonicalization on Windows when emitting hyperlinks. - [PERF #​3184](BurntSushi/ripgrep#3184): Improve performance of large values with `-A/--after-context`. Bug fixes: - [BUG #​829](BurntSushi/ripgrep#829), [BUG #​2731](BurntSushi/ripgrep#2731), [BUG #​2747](BurntSushi/ripgrep#2747), [BUG #​2770](BurntSushi/ripgrep#2770), [BUG #​2778](BurntSushi/ripgrep#2778), [BUG #​2836](BurntSushi/ripgrep#2836), [BUG #​2933](BurntSushi/ripgrep#2933), [BUG #​3067](BurntSushi/ripgrep#3067): Fix bug related to gitignores from parent directories. - [BUG #​1332](BurntSushi/ripgrep#1332), [BUG #​3001](BurntSushi/ripgrep#3001): Make `rg -vf file` where `file` is empty match everything. - [BUG #​2177](BurntSushi/ripgrep#2177): Ignore a UTF-8 BOM marker at the start of `.gitignore` (and similar files). - [BUG #​2750](BurntSushi/ripgrep#2750): Fix memory usage regression for some truly large gitignore files. - [BUG #​2944](BurntSushi/ripgrep#2944): Fix a bug where the "bytes searched" in `--stats` output could be incorrect. - [BUG #​2990](BurntSushi/ripgrep#2990): Fix a bug where ripgrep would mishandle globs that ended with a `.`. - [BUG #​2094](BurntSushi/ripgrep#2094), [BUG #​3076](BurntSushi/ripgrep#3076): Fix bug with `-m/--max-count` and `-U/--multiline` showing too many matches. - [BUG #​3100](BurntSushi/ripgrep#3100): Preserve line terminators when using `-r/--replace` flag. - [BUG #​3108](BurntSushi/ripgrep#3108): Fix a bug where `-q --files-without-match` inverted the exit code. - [BUG #​3131](BurntSushi/ripgrep#3131): Document inconsistency between `-c/--count` and `--files-with-matches`. - [BUG #​3135](BurntSushi/ripgrep#3135): Fix rare panic for some classes of large regexes on large haystacks. - [BUG #​3140](BurntSushi/ripgrep#3140): Ensure hyphens in flag names are escaped in the roff text for the man page. - [BUG #​3155](BurntSushi/ripgrep#3155): Statically compile PCRE2 into macOS release artifacts on `aarch64`. - [BUG #​3173](BurntSushi/ripgrep#3173): Fix ancestor ignore filter bug when searching whitelisted hidden files. - [BUG #​3178](BurntSushi/ripgrep#3178): Fix bug causing incorrect summary statistics with `--json` flag. - [BUG #​3179](BurntSushi/ripgrep#3179): Fix gitignore bug when searching absolute paths with global gitignores. - [BUG #​3180](BurntSushi/ripgrep#3180): Fix a panicking bug when using `-U/--multiline` and `-r/--replace`. Feature enhancements: - Many enhancements to the default set of file types available for filtering. - [FEATURE #​1872](BurntSushi/ripgrep#1872): Make `-r/--replace` work with `--json`. - [FEATURE #​2708](BurntSushi/ripgrep#2708): Completions for the fish shell take ripgrep's config file into account. - [FEATURE #​2841](BurntSushi/ripgrep#2841): Add `italic` to the list of available style attributes in `--color`. - [FEATURE #​2842](BurntSushi/ripgrep#2842): Directories containing `.jj` are now treated as git repositories. - [FEATURE #​2849](BurntSushi/ripgrep#2849): When using multithreading, schedule files to search in order given on CLI. - [FEATURE #​2943](BurntSushi/ripgrep#2943): Add `aarch64` release artifacts for Windows. - [FEATURE #​3024](BurntSushi/ripgrep#3024): Add `highlight` color type, for styling non-matching text in a matching line. - [FEATURE #​3048](BurntSushi/ripgrep#3048): Globs in ripgrep (and the `globset` crate) now support nested alternates. - [FEATURE #​3096](BurntSushi/ripgrep#3096): Improve completions for `--hyperlink-format` in bash and fish. - [FEATURE #​3102](BurntSushi/ripgrep#3102): Improve completions for `--hyperlink-format` in zsh. </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDguNiIsInVwZGF0ZWRJblZlciI6IjQxLjE0OC42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
15.0.0 (2025-10-15) =================== ripgrep 15 is a new major version release of ripgrep that mostly has bug fixes, some minor performance improvements and minor new features. Here are some highlights: * Several bugs around gitignore matching have been fixed. This includes a commonly reported bug related to applying gitignore rules from parent directories. * A memory usage regression when handling very large gitignore files has been fixed. * `rg -vf file`, where `file` is empty, now matches everything. * The `-r/--replace` flag now works with `--json`. * A subset of Jujutsu (`jj`) repositories are now treated as if they were git repositories. That is, ripgrep will respect `jj`'s gitignores. * Globs can now use nested curly braces. Platform support: * `aarch64` for Windows now has release artifacts. * `powerpc64` no longer has release artifacts generated for it. The CI release workflow stopped working, and I didn't deem it worth my time to debug it. If someone wants this and can test it, I'd be happy to add it back. * ripgrep binaries are now compiled with full LTO enabled. You may notice small performance improvements from this and a modest decrease in binary size. Performance improvements: * [PERF #2111](BurntSushi/ripgrep#2111): Don't resolve helper binaries on Windows when `-z/--search-zip` isn't used. * [PERF #2865](BurntSushi/ripgrep#2865): Avoid using path canonicalization on Windows when emitting hyperlinks. * [PERF #3184](BurntSushi/ripgrep#3184): Improve performance of large values with `-A/--after-context`. Bug fixes: * [BUG #829](BurntSushi/ripgrep#829), [BUG #2731](BurntSushi/ripgrep#2731), [BUG #2747](BurntSushi/ripgrep#2747), [BUG #2770](BurntSushi/ripgrep#2770), [BUG #2778](BurntSushi/ripgrep#2778), [BUG #2836](BurntSushi/ripgrep#2836), [BUG #2933](BurntSushi/ripgrep#2933), [BUG #3067](BurntSushi/ripgrep#3067): Fix bug related to gitignores from parent directories. * [BUG #1332](BurntSushi/ripgrep#1332), [BUG #3001](BurntSushi/ripgrep#3001): Make `rg -vf file` where `file` is empty match everything. * [BUG #2177](BurntSushi/ripgrep#2177): Ignore a UTF-8 BOM marker at the start of `.gitignore` (and similar files). * [BUG #2750](BurntSushi/ripgrep#2750): Fix memory usage regression for some truly large gitignore files. * [BUG #2944](BurntSushi/ripgrep#2944): Fix a bug where the "bytes searched" in `--stats` output could be incorrect. * [BUG #2990](BurntSushi/ripgrep#2990): Fix a bug where ripgrep would mishandle globs that ended with a `.`. * [BUG #2094](BurntSushi/ripgrep#2094), [BUG #3076](BurntSushi/ripgrep#3076): Fix bug with `-m/--max-count` and `-U/--multiline` showing too many matches. * [BUG #3100](BurntSushi/ripgrep#3100): Preserve line terminators when using `-r/--replace` flag. * [BUG #3108](BurntSushi/ripgrep#3108): Fix a bug where `-q --files-without-match` inverted the exit code. * [BUG #3131](BurntSushi/ripgrep#3131): Document inconsistency between `-c/--count` and `--files-with-matches`. * [BUG #3135](BurntSushi/ripgrep#3135): Fix rare panic for some classes of large regexes on large haystacks. * [BUG #3140](BurntSushi/ripgrep#3140): Ensure hyphens in flag names are escaped in the roff text for the man page. * [BUG #3155](BurntSushi/ripgrep#3155): Statically compile PCRE2 into macOS release artifacts on `aarch64`. * [BUG #3173](BurntSushi/ripgrep#3173): Fix ancestor ignore filter bug when searching whitelisted hidden files. * [BUG #3178](BurntSushi/ripgrep#3178): Fix bug causing incorrect summary statistics with `--json` flag. * [BUG #3179](BurntSushi/ripgrep#3179): Fix gitignore bug when searching absolute paths with global gitignores. * [BUG #3180](BurntSushi/ripgrep#3180): Fix a panicking bug when using `-U/--multiline` and `-r/--replace`. Feature enhancements: * Many enhancements to the default set of file types available for filtering. * [FEATURE #1872](BurntSushi/ripgrep#1872): Make `-r/--replace` work with `--json`. * [FEATURE #2708](BurntSushi/ripgrep#2708): Completions for the fish shell take ripgrep's config file into account. * [FEATURE #2841](BurntSushi/ripgrep#2841): Add `italic` to the list of available style attributes in `--color`. * [FEATURE #2842](BurntSushi/ripgrep#2842): Directories containing `.jj` are now treated as git repositories. * [FEATURE #2849](BurntSushi/ripgrep#2849): When using multithreading, schedule files to search in order given on CLI. * [FEATURE #2943](BurntSushi/ripgrep#2943): Add `aarch64` release artifacts for Windows. * [FEATURE #3024](BurntSushi/ripgrep#3024): Add `highlight` color type, for styling non-matching text in a matching line. * [FEATURE #3048](BurntSushi/ripgrep#3048): Globs in ripgrep (and the `globset` crate) now support nested alternates. * [FEATURE #3096](BurntSushi/ripgrep#3096): Improve completions for `--hyperlink-format` in bash and fish. * [FEATURE #3102](BurntSushi/ripgrep#3102): Improve completions for `--hyperlink-format` in zsh.
15.0.0 (2025-10-15) =================== ripgrep 15 is a new major version release of ripgrep that mostly has bug fixes, some minor performance improvements and minor new features. Here are some highlights: * Several bugs around gitignore matching have been fixed. This includes a commonly reported bug related to applying gitignore rules from parent directories. * A memory usage regression when handling very large gitignore files has been fixed. * `rg -vf file`, where `file` is empty, now matches everything. * The `-r/--replace` flag now works with `--json`. * A subset of Jujutsu (`jj`) repositories are now treated as if they were git repositories. That is, ripgrep will respect `jj`'s gitignores. * Globs can now use nested curly braces. Platform support: * `aarch64` for Windows now has release artifacts. * `powerpc64` no longer has release artifacts generated for it. The CI release workflow stopped working, and I didn't deem it worth my time to debug it. If someone wants this and can test it, I'd be happy to add it back. * ripgrep binaries are now compiled with full LTO enabled. You may notice small performance improvements from this and a modest decrease in binary size. Performance improvements: * [PERF #2111](BurntSushi/ripgrep#2111): Don't resolve helper binaries on Windows when `-z/--search-zip` isn't used. * [PERF #2865](BurntSushi/ripgrep#2865): Avoid using path canonicalization on Windows when emitting hyperlinks. * [PERF #3184](BurntSushi/ripgrep#3184): Improve performance of large values with `-A/--after-context`. Bug fixes: * [BUG #829](BurntSushi/ripgrep#829), [BUG #2731](BurntSushi/ripgrep#2731), [BUG #2747](BurntSushi/ripgrep#2747), [BUG #2770](BurntSushi/ripgrep#2770), [BUG #2778](BurntSushi/ripgrep#2778), [BUG #2836](BurntSushi/ripgrep#2836), [BUG #2933](BurntSushi/ripgrep#2933), [BUG #3067](BurntSushi/ripgrep#3067): Fix bug related to gitignores from parent directories. * [BUG #1332](BurntSushi/ripgrep#1332), [BUG #3001](BurntSushi/ripgrep#3001): Make `rg -vf file` where `file` is empty match everything. * [BUG #2177](BurntSushi/ripgrep#2177): Ignore a UTF-8 BOM marker at the start of `.gitignore` (and similar files). * [BUG #2750](BurntSushi/ripgrep#2750): Fix memory usage regression for some truly large gitignore files. * [BUG #2944](BurntSushi/ripgrep#2944): Fix a bug where the "bytes searched" in `--stats` output could be incorrect. * [BUG #2990](BurntSushi/ripgrep#2990): Fix a bug where ripgrep would mishandle globs that ended with a `.`. * [BUG #2094](BurntSushi/ripgrep#2094), [BUG #3076](BurntSushi/ripgrep#3076): Fix bug with `-m/--max-count` and `-U/--multiline` showing too many matches. * [BUG #3100](BurntSushi/ripgrep#3100): Preserve line terminators when using `-r/--replace` flag. * [BUG #3108](BurntSushi/ripgrep#3108): Fix a bug where `-q --files-without-match` inverted the exit code. * [BUG #3131](BurntSushi/ripgrep#3131): Document inconsistency between `-c/--count` and `--files-with-matches`. * [BUG #3135](BurntSushi/ripgrep#3135): Fix rare panic for some classes of large regexes on large haystacks. * [BUG #3140](BurntSushi/ripgrep#3140): Ensure hyphens in flag names are escaped in the roff text for the man page. * [BUG #3155](BurntSushi/ripgrep#3155): Statically compile PCRE2 into macOS release artifacts on `aarch64`. * [BUG #3173](BurntSushi/ripgrep#3173): Fix ancestor ignore filter bug when searching whitelisted hidden files. * [BUG #3178](BurntSushi/ripgrep#3178): Fix bug causing incorrect summary statistics with `--json` flag. * [BUG #3179](BurntSushi/ripgrep#3179): Fix gitignore bug when searching absolute paths with global gitignores. * [BUG #3180](BurntSushi/ripgrep#3180): Fix a panicking bug when using `-U/--multiline` and `-r/--replace`. Feature enhancements: * Many enhancements to the default set of file types available for filtering. * [FEATURE #1872](BurntSushi/ripgrep#1872): Make `-r/--replace` work with `--json`. * [FEATURE #2708](BurntSushi/ripgrep#2708): Completions for the fish shell take ripgrep's config file into account. * [FEATURE #2841](BurntSushi/ripgrep#2841): Add `italic` to the list of available style attributes in `--color`. * [FEATURE #2842](BurntSushi/ripgrep#2842): Directories containing `.jj` are now treated as git repositories. * [FEATURE #2849](BurntSushi/ripgrep#2849): When using multithreading, schedule files to search in order given on CLI. * [FEATURE #2943](BurntSushi/ripgrep#2943): Add `aarch64` release artifacts for Windows. * [FEATURE #3024](BurntSushi/ripgrep#3024): Add `highlight` color type, for styling non-matching text in a matching line. * [FEATURE #3048](BurntSushi/ripgrep#3048): Globs in ripgrep (and the `globset` crate) now support nested alternates. * [FEATURE #3096](BurntSushi/ripgrep#3096): Improve completions for `--hyperlink-format` in bash and fish. * [FEATURE #3102](BurntSushi/ripgrep#3102): Improve completions for `--hyperlink-format` in zsh.
15.0.0 (2025-10-15) =================== ripgrep 15 is a new major version release of ripgrep that mostly has bug fixes, some minor performance improvements and minor new features. Here are some highlights: * Several bugs around gitignore matching have been fixed. This includes a commonly reported bug related to applying gitignore rules from parent directories. * A memory usage regression when handling very large gitignore files has been fixed. * `rg -vf file`, where `file` is empty, now matches everything. * The `-r/--replace` flag now works with `--json`. * A subset of Jujutsu (`jj`) repositories are now treated as if they were git repositories. That is, ripgrep will respect `jj`'s gitignores. * Globs can now use nested curly braces. Platform support: * `aarch64` for Windows now has release artifacts. * `powerpc64` no longer has release artifacts generated for it. The CI release workflow stopped working, and I didn't deem it worth my time to debug it. If someone wants this and can test it, I'd be happy to add it back. * ripgrep binaries are now compiled with full LTO enabled. You may notice small performance improvements from this and a modest decrease in binary size. Performance improvements: * [PERF #2111](BurntSushi/ripgrep#2111): Don't resolve helper binaries on Windows when `-z/--search-zip` isn't used. * [PERF #2865](BurntSushi/ripgrep#2865): Avoid using path canonicalization on Windows when emitting hyperlinks. * [PERF #3184](BurntSushi/ripgrep#3184): Improve performance of large values with `-A/--after-context`. Bug fixes: * [BUG #829](BurntSushi/ripgrep#829), [BUG #2731](BurntSushi/ripgrep#2731), [BUG #2747](BurntSushi/ripgrep#2747), [BUG #2770](BurntSushi/ripgrep#2770), [BUG #2778](BurntSushi/ripgrep#2778), [BUG #2836](BurntSushi/ripgrep#2836), [BUG #2933](BurntSushi/ripgrep#2933), [BUG #3067](BurntSushi/ripgrep#3067): Fix bug related to gitignores from parent directories. * [BUG #1332](BurntSushi/ripgrep#1332), [BUG #3001](BurntSushi/ripgrep#3001): Make `rg -vf file` where `file` is empty match everything. * [BUG #2177](BurntSushi/ripgrep#2177): Ignore a UTF-8 BOM marker at the start of `.gitignore` (and similar files). * [BUG #2750](BurntSushi/ripgrep#2750): Fix memory usage regression for some truly large gitignore files. * [BUG #2944](BurntSushi/ripgrep#2944): Fix a bug where the "bytes searched" in `--stats` output could be incorrect. * [BUG #2990](BurntSushi/ripgrep#2990): Fix a bug where ripgrep would mishandle globs that ended with a `.`. * [BUG #2094](BurntSushi/ripgrep#2094), [BUG #3076](BurntSushi/ripgrep#3076): Fix bug with `-m/--max-count` and `-U/--multiline` showing too many matches. * [BUG #3100](BurntSushi/ripgrep#3100): Preserve line terminators when using `-r/--replace` flag. * [BUG #3108](BurntSushi/ripgrep#3108): Fix a bug where `-q --files-without-match` inverted the exit code. * [BUG #3131](BurntSushi/ripgrep#3131): Document inconsistency between `-c/--count` and `--files-with-matches`. * [BUG #3135](BurntSushi/ripgrep#3135): Fix rare panic for some classes of large regexes on large haystacks. * [BUG #3140](BurntSushi/ripgrep#3140): Ensure hyphens in flag names are escaped in the roff text for the man page. * [BUG #3155](BurntSushi/ripgrep#3155): Statically compile PCRE2 into macOS release artifacts on `aarch64`. * [BUG #3173](BurntSushi/ripgrep#3173): Fix ancestor ignore filter bug when searching whitelisted hidden files. * [BUG #3178](BurntSushi/ripgrep#3178): Fix bug causing incorrect summary statistics with `--json` flag. * [BUG #3179](BurntSushi/ripgrep#3179): Fix gitignore bug when searching absolute paths with global gitignores. * [BUG #3180](BurntSushi/ripgrep#3180): Fix a panicking bug when using `-U/--multiline` and `-r/--replace`. Feature enhancements: * Many enhancements to the default set of file types available for filtering. * [FEATURE #1872](BurntSushi/ripgrep#1872): Make `-r/--replace` work with `--json`. * [FEATURE #2708](BurntSushi/ripgrep#2708): Completions for the fish shell take ripgrep's config file into account. * [FEATURE #2841](BurntSushi/ripgrep#2841): Add `italic` to the list of available style attributes in `--color`. * [FEATURE #2842](BurntSushi/ripgrep#2842): Directories containing `.jj` are now treated as git repositories. * [FEATURE #2849](BurntSushi/ripgrep#2849): When using multithreading, schedule files to search in order given on CLI. * [FEATURE #2943](BurntSushi/ripgrep#2943): Add `aarch64` release artifacts for Windows. * [FEATURE #3024](BurntSushi/ripgrep#3024): Add `highlight` color type, for styling non-matching text in a matching line. * [FEATURE #3048](BurntSushi/ripgrep#3048): Globs in ripgrep (and the `globset` crate) now support nested alternates. * [FEATURE #3096](BurntSushi/ripgrep#3096): Improve completions for `--hyperlink-format` in bash and fish. * [FEATURE #3102](BurntSushi/ripgrep#3102): Improve completions for `--hyperlink-format` in zsh.
The goal is to make the completion for
rg --hyperlink-format v<TAB>work in the fish shell.These are not exhaustive (the user can also specify custom formats). If this ever makes a difference, perhaps
fn doc_choices_are_exhaustive(&self) -> boolcan be added to theFlagstrait.The
grep+value necessitated a change to a test.I'm not sure whether there's a good way to generate the choices directly from
hyperlink_aliases.rsas a&'static [&'static str]. The simplest would be to reorganizehyperlink_aliases.rsto keep the keys and values in separate arrays, but that would be less readable. This would be easy if the return type ofdoc_choicescould be changed. OTOH, the values already need to be kept in sync with the long-form description inside the help text, which currently also has to be an&'static str.