Repository navigation
fix: don't drop fish completions that start with the app name - #2495
Conversation
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>
91c7a52 to
c2643a9
Compare
Juneezee
left a comment
There was a problem hiding this comment.
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.
cli/autocomplete/fish_autocomplete
Lines 24 to 34 in 4b0f1f4
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.
What type of PR is this?
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 namedapp, a subcommandapplyis never offered. In fish 4.9.3, withapp completion fishsourced:The same goes for any name with the app's name as a prefix (
cliandclient,dbanddbinit). 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
TestCompletionFishKeepsSuggestionsStartingWithAppName, in the style of the other fish script tests. It fails onmain.apply,status, flags), as above. Flag completion (app --) is unchanged.make(generate, vet, tests, binary size, gfmrun),make lintandmake v3diffpass.go test -racepasses, as do the tests withurfave_cli_no_template,urfave_cli_no_docsandurfave_cli_no_suggest.The change and the test were written with Claude Code (AI).
Release Notes
🤖 Generated with Claude Code