1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-09-16 08:26:28 +02:00

complete: improvements for the --hyperlink-format flag

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
This commit is contained in:
Ilya Grigoriev
2025-07-06 16:05:15 -07:00
committed by Andrew Gallant
parent 458ca71e96
commit 419a8910d1
2 changed files with 18 additions and 2 deletions

View File

@@ -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)

View File

@@ -3008,6 +3008,19 @@ https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
&DOC
}
fn doc_choices(&self) -> &'static [&'static str] {
static CHOICES: LazyLock<Vec<String>> = LazyLock::new(|| {
let mut aliases = grep::printer::hyperlink_aliases();
aliases.sort_by_key(|alias| {
alias.display_priority().unwrap_or(u16::MAX)
});
aliases.iter().map(|alias| alias.name().to_string()).collect()
});
static BORROWED: LazyLock<Vec<&'static str>> =
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]+$",
)
}
}