1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-03-17 20:28:03 +02:00

complete/fish: Fix syntax for negated options

And also, negated options don't take arguments.

Specifically, the fish completion generator currently forgets to add
`-l` to negation options, leading to a list of these errors:

    complete: too many arguments

    ~/.config/fish/completions/rg.fish (line 146):
    complete -c rg -n '__fish_use_subcommand'  no-sort-files -d '(DEPRECATED) Sort results by file path.'
    ^
    from sourcing file ~/.config/fish/completions/rg.fish

    (Type 'help complete' for related documentation)

To reproduce, run `fish -c 'rg --generate=complete-fish | source'`.

It also potentially suggests a list of choices for negation options,
even though those never take arguments. That case doesn't occur with
any of the current options but it's an easy fix.

Fixes #2659, Closes #2655
This commit is contained in:
Jan Verbeek 2023-11-27 10:54:35 +01:00 committed by Andrew Gallant
parent 2e81a7adfe
commit 8575d26179
2 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,8 @@ This is a patch release with a few small bug fixes.
Bug fixes:
* [BUG #2659](https://github.com/BurntSushi/ripgrep/issues/2659):
Fix Fish shell completions.
* [BUG #2662](https://github.com/BurntSushi/ripgrep/issues/2662):
Fix typo in documentation for `-i/--ignore-case`.

View File

@ -35,10 +35,11 @@ pub(crate) fn generate() -> String {
.replace("!DOC!", &doc),
);
if let Some(negated) = flag.name_negated() {
let long = format!("-l '{}'", negated.replace("'", "\\'"));
out.push_str(
&template
&TEMPLATE
.replace("!SHORT!", "")
.replace("!LONG!", &negated)
.replace("!LONG!", &long)
.replace("!DOC!", &doc),
);
}