summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Verbeek <jan.verbeek@posteo.nl>2023-11-27 10:54:35 +0100
committerAndrew Gallant <jamslam@gmail.com>2023-11-27 21:17:12 -0500
commit8575d261790fe393d1768d12b3336cbb4cf0a9fc (patch)
tree96986a384485c060753d7b14d39126f657688e19
parent2e81a7adfeeb9a213786b8331b244f97e7b66657 (diff)
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
-rw-r--r--CHANGELOG.md2
-rw-r--r--crates/core/flags/complete/fish.rs5
2 files changed, 5 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2d8e3b9..a8e2207d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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`.
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),
);
}