diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ed953ac..65ed698b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ Feature enhancements: Add `highlight` color type, for styling non-matching text in a matching line. * [FEATURE #3048](https://github.com/BurntSushi/ripgrep/pull/3048): Globs in ripgrep (and the `globset` crate) now support nested alternates. +* [FEATURE #3096](https://github.com/BurntSushi/ripgrep/pull/3096): + Improve completions for `--hyperlink-format` in bash and fish. 14.1.1 (2024-09-08) diff --git a/crates/core/flags/defs.rs b/crates/core/flags/defs.rs index 7b9af14f..30f5cdc8 100644 --- a/crates/core/flags/defs.rs +++ b/crates/core/flags/defs.rs @@ -3008,6 +3008,19 @@ https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda &DOC } + fn doc_choices(&self) -> &'static [&'static str] { + static CHOICES: LazyLock> = LazyLock::new(|| { + let mut aliases = grep::printer::hyperlink_aliases(); + aliases.sort_by_key(|alias| { + alias.display_priority().unwrap_or(i16::MAX) + }); + aliases.iter().map(|alias| alias.name().to_string()).collect() + }); + static BORROWED: LazyLock> = + LazyLock::new(|| CHOICES.iter().map(|name| &**name).collect()); + &*BORROWED + } + fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> { let v = v.unwrap_value(); let string = convert::str(&v)?; @@ -7724,9 +7737,10 @@ mod tests { assert!( choice.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' - || c == ':'), + || c == ':' + || c == '+'), "choice '{choice}' for flag '{long}' does not match \ - ^[-:0-9A-Za-z]+$", + ^[-+:0-9A-Za-z]+$", ) } }