Fix: correct function and variable naming in fish completion script#2286
Fix: correct function and variable naming in fish completion script#2286TimSoethout wants to merge 1 commit intourfave:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes formatting issues in the Fish shell completion script template used by cli completion fish, correcting Go fmt.Sprintf placeholder usage so generated Fish functions/completions render with the expected command name and without %!-style formatting errors.
Changes:
- Updated Fish completion template placeholders from
%[1]to%[1]sfor correct Go string substitution. - Escaped
printfformat verbs (%s→%%s) so they remain literal in the generated Fish script.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| function __%[1]s_perform_completion | ||
| # Extract all args except the last one | ||
| set -l args (commandline -opc) |
There was a problem hiding this comment.
not committed, not adding much
There was a problem hiding this comment.
@TimSoethout Can you add or update an existing test case for this ?
There was a problem hiding this comment.
I had a testcase, but it didn't make much sense. It was more of a regression test which specifically pattern matched on the specific wrong/correct output syntax of the earlier bug/error.
There was no test in place before, so left it as is.
WDYT would make a valuable test case?
Ideally actually having fish source the output without errors, but not sure if we want to go that far?
This pull request updates the Fish shell autocomplete script to fix formatting and variable substitution issues, ensuring correct function naming and output formatting for command completions.
Improvements to autocomplete script:
%[1]sinstead of%[1], ensuring proper variable substitution for command names throughout the script (autocomplete/fish_autocomplete). [1] [2]printfformatting to use the correct Fish and printf syntax, preventing formatting errors in completion output (autocomplete/fish_autocomplete).What type of PR is this?
What this PR does / why we need it:
PR #2270 introduced dynamic fish completions but used invalid Go format specifiers in the fish autocomplete template. The format string
%[1]was missing the type specifiers, causingfmt.Sprintfto produce malformed output like__%!_(string=appname)perform_completioninstead of__appname_perform_completion.Changes:
autocomplete/fish_autocomplete: Fixed format specifiers from%[1]to%[1]s(7 occurrences). Also escaped%sas%%sin the printf statements so they remain literal in the generated fish script.Which issue(s) this PR fixes:
Fixes #2285
Testing
TestCompletionFishFormataddedRelease Notes
@TimSoethout assisted by copilot.