From 8575d261790fe393d1768d12b3336cbb4cf0a9fc Mon Sep 17 00:00:00 2001 From: Jan Verbeek Date: Mon, 27 Nov 2023 10:54:35 +0100 Subject: 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 --- crates/core/flags/complete/fish.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/core/flags/complete/fish.rs b/crates/core/flags/complete/fish.rs index 6b28421f..e55d72e3 100644 --- a/crates/core/flags/complete/fish.rs +++ b/crates/core/flags/complete/fish.rs @@ -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), ); } -- cgit v1.2.3