Skip to content

fix: don't drop fish completions that start with the app name - #2495

Merged
Juneezee merged 1 commit into
urfave:mainfrom
vidigoat:fix/fish-completion-app-name-prefix
Oct 24, 2026
Merged

Juneezee merged 1 commit into
urfave:mainfrom
vidigoat:fix/fish-completion-app-name-prefix

Conversation

@vidigoat

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • bug

What this PR does / why we need it:

The fish completion script skips every suggestion that starts with the program's name (if not string match -q -- "%[1]s*" $line), so for an app named app, a subcommand apply is never offered. In fish 4.9.3, with app completion fish sourced:

$ complete -C "app "        # before: apply missing      after:
cache                                                    apply    apply changes
help    Shows a list of ...                              cache
status  show status                                      help     Shows a list of ...
                                                         status   show status
$ complete -C "app ap"      # before: no apply           after: apply  apply changes

The same goes for any name with the app's name as a prefix (cli and client, db and dbinit). Errors already go to /dev/null, and with completion disabled the help text that comes back is indented, so it never starts with the app name either. The filter only ever removed real suggestions, so I removed it. bash and zsh have no such filter.

Which issue(s) this PR fixes:

None, found while testing the completion scripts in real shells.

Testing

  • New TestCompletionFishKeepsSuggestionsStartingWithAppName, in the style of the other fish script tests. It fails on main.
  • Checked in fish 4.9.3 with a test app (apply, status, flags), as above. Flag completion (app --) is unchanged.
  • make (generate, vet, tests, binary size, gfmrun), make lint and make v3diff pass. go test -race passes, as do the tests with urfave_cli_no_template, urfave_cli_no_docs and urfave_cli_no_suggest.

The change and the test were written with Claude Code (AI).

Release Notes

Fish completion no longer drops suggestions that start with the program's name.

🤖 Generated with Claude Code

@vidigoat
vidigoat requested a review from a team as a code owner October 24, 2026 07:56
The fish completion script skipped every suggestion that started with
the program's name, so for an app named "app" a subcommand "apply" was
never offered. Errors already go to /dev/null, so the filter only ever
removed real suggestions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
@Juneezee
Juneezee force-pushed the fix/fish-completion-app-name-prefix branch from 91c7a52 to c2643a9 Compare October 24, 2026 16:34

@Juneezee Juneezee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I reproduced this in fish 4.9.3 with an app named app. On main, complete -C "app ap" drops the apply and app-config subcommands. With this PR both show up, and flag completion is unchanged.

The filter also dropped values from a custom ShellComplete. A load subcommand that suggests app.yaml and base.yaml only offered base.yaml on main.

for line in $results
if not string match -q -- "%[1]s*" $line
set -l parts (string split -m 1 ":" -- "$line")
if test (count $parts) -eq 2
printf "%%s\t%%s\n" "$parts[1]" "$parts[2]"
else
printf "%%s\n" "$line"
end
end
end
end

I also checked the case the filter might have been for. With EnableShellCompletion: false, the errors go to stderr and the help on stdout is indented, so the filter didn't catch either one. I couldn't find any output it was needed for.

I rebased this onto main and squashed the two commits into one. The new test fails on main, and the full test suite passes.

LGTM.

@Juneezee
Juneezee merged commit 7166c48 into urfave:main Oct 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants