Skip to content

fix: complete the word at the cursor in the PowerShell script - #2518

Open
b84330808 wants to merge 1 commit into
urfave:mainfrom
b84330808:fix/pwsh-completion-current-word
Open

b84330808 wants to merge 1 commit into
urfave:mainfrom
b84330808:fix/pwsh-completion-current-word

Conversation

@b84330808

Copy link
Copy Markdown

What type of PR is this?

  • bug

What this PR does / why we need it:

The PowerShell completion script ran the whole command line, including the word being completed, and showed every suggestion it got back. PowerShell doesn't filter native completer results, so myapp st<Tab> offered every subcommand, and myapp sync<Tab> offered the arguments of sync instead of completing sync itself. Like the bash and fish scripts, it now passes only the words before the cursor (plus the current word when it's a flag) and keeps only suggestions that start with the current word. It also fixes the order of the scriptblock's parameter names; native completers get $wordToComplete, $commandAst, $cursorPosition.

Which issue(s) this PR fixes:

None filed.

Testing

TestCompletionPowershellCompletesCurrentWord runs the generated script through TabExpansion2 in Windows PowerShell with a .cmd stand-in for the app. It's skipped on other platforms.

Release Notes

PowerShell completion now completes the word at the cursor instead of listing every suggestion or completing a fully typed subcommand's arguments.

I used Claude Code to write this change.

The PowerShell completer ran the whole command line, including the word
being completed, and showed every suggestion it got back. So
`myapp st<Tab>` offered all subcommands, and `myapp sync<Tab>` offered
the arguments of sync instead of completing sync itself.

Like the bash and fish scripts, pass only the words before the cursor,
plus the current word when it is a flag, and keep only the suggestions
that start with the current word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@b84330808
b84330808 requested a review from a team as a code owner November 1, 2026 14:36

This branch has not been deployed

No deployments
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.

1 participant