Skip to content
Myr

complete: improvements for the `--hyperlink-format` flag

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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

authored by Ilya Grigoriev · committed by Andrew Gallant · parent 66aa4a6 · Browse files · 2 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−2 removed

  • other:+18 added−2 removed

2 files+18 added−2 removed

modified:crates/core/flags/defs.rs+16 added-2 removed
3006 unmodified lines
3007 });3008 &DOC3009 }30103011 fn doc_choices(&self) -> &'static [&'static str] {3012 static CHOICES: LazyLock<Vec<String>> = LazyLock::new(|| {3013 let mut aliases = grep::printer::hyperlink_aliases();3014 aliases.sort_by_key(|alias| {3015 alias.display_priority().unwrap_or(i16::MAX)3016 });3017 aliases.iter().map(|alias| alias.name().to_string()).collect()3018 });3019 static BORROWED: LazyLock<Vec<&'static str>> =3020 LazyLock::new(|| CHOICES.iter().map(|name| &**name).collect());3021 &*BORROWED3022 }30233024 fn update(&self, v: FlagValue, args: &mut LowArgs) -> anyhow::Result<()> {3025 let v = v.unwrap_value();3026 let string = convert::str(&v)?;3027 let format = string.parse().context("invalid hyperlink format")?;
4708 unmodified lines
7736 for choice in flag.doc_choices() {7737 assert!(7738 choice.chars().all(|c| c.is_ascii_alphanumeric()7739 || c == '-'7727 || c == ':'),7740 || c == ':'7741 || c == '+'),7742 "choice '{choice}' for flag '{long}' does not match \7729 ^[-:0-9A-Za-z]+$",7743 ^[-+:0-9A-Za-z]+$",7744 )7745 }7746 }7747 }
1 unmodified line
modified:CHANGELOG.md+2 added
45 unmodified lines
46* [FEATURE #3024](https://github.com/BurntSushi/ripgrep/issues/3024):47 Add `highlight` color type, for styling non-matching text in a matching line.48* [FEATURE #3048](https://github.com/BurntSushi/ripgrep/pull/3048):49 Globs in ripgrep (and the `globset` crate) now support nested alternates.50* [FEATURE #3096](https://github.com/BurntSushi/ripgrep/pull/3096):51 Improve completions for `--hyperlink-format` in bash and fish.52535414.1.1 (2024-09-08)55===================
1709 unmodified lines