From fb6dec1413290a326d27a816b852909e88d4d537 Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Mon, 21 Apr 2025 09:07:51 -0400 Subject: [PATCH 1/2] Fix:(issue_2105) Ensure fish completion works --- command_setup.go | 2 +- completion.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command_setup.go b/command_setup.go index 69b3ca198c..c50ff9100d 100644 --- a/command_setup.go +++ b/command_setup.go @@ -88,7 +88,7 @@ func (cmd *Command) setupDefaults(osArgs []string) { cmd.SuggestCommandFunc = suggestCommand } - if cmd.EnableShellCompletion || cmd.Root().shellCompletion { + if isRoot { completionCommand := buildCompletionCommand(cmd.Name) if cmd.ShellCompletionCommandName != "" { diff --git a/completion.go b/completion.go index d778380474..789c9d0a7a 100644 --- a/completion.go +++ b/completion.go @@ -30,7 +30,7 @@ var ( return fmt.Sprintf(string(b), appName), err }, "fish": func(c *Command, appName string) (string, error) { - return c.ToFishCompletion() + return c.Root().ToFishCompletion() }, "pwsh": func(c *Command, appName string) (string, error) { b, err := autoCompleteFS.ReadFile("autocomplete/powershell_autocomplete.ps1") From 86236b6bd24191c29a57ad58f444d35b5fcfc49e Mon Sep 17 00:00:00 2001 From: Naveen Gogineni Date: Mon, 21 Apr 2025 09:16:25 -0400 Subject: [PATCH 2/2] Fix tests --- command_setup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command_setup.go b/command_setup.go index c50ff9100d..060b9ba9ba 100644 --- a/command_setup.go +++ b/command_setup.go @@ -88,7 +88,7 @@ func (cmd *Command) setupDefaults(osArgs []string) { cmd.SuggestCommandFunc = suggestCommand } - if isRoot { + if isRoot && cmd.EnableShellCompletion { completionCommand := buildCompletionCommand(cmd.Name) if cmd.ShellCompletionCommandName != "" {