Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powershell support for native completions #3918

Open
epage opened this issue Jul 13, 2022 · 2 comments · May be fixed by #5338
Open

powershell support for native completions #3918

epage opened this issue Jul 13, 2022 · 2 comments · May be fixed by #5338
Labels
A-completion Area: completion generator E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. 💸 $20

Comments

@epage
Copy link
Member

epage commented Jul 13, 2022

See #3166 for more context

@epage epage added A-completion Area: completion generator E-easy Call for participation: Experience needed to fix: Easy / not much labels Jul 13, 2022
@epage epage added the 💸 $20 label Sep 13, 2022
@Rhondapetal
Copy link

Hello

@epage epage added the E-help-wanted Call for participation: Help is requested to fix this issue. label Sep 20, 2022
@epage
Copy link
Member Author

epage commented May 24, 2023

For Powershell

Register-ArgumentCompleter
        -CommandName <String[]>
        -ScriptBlock <ScriptBlock>
        [-Native]
        [<CommonParameters>]

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.2

The block receives

When you specify the Native parameter, the script block must take the following parameters in the specified order. The names of the parameters aren't important because PowerShell passes in the values by position.

  • $wordToComplete (Position 0) - This parameter is set to value the user has provided before they pressed Tab. Your script block should use this value to determine tab completion values.
  • $commandAst (Position 1) - This parameter is set to the Abstract Syntax Tree (AST) for the current input line. For more information, see Ast Class.
  • $cursorPosition (Position 2) - This parameter is set to the position of the cursor when the user pressed Tab.

The block provides CompletionResult

The CompletionResult object allows you to provide additional details to each returned value:

  • completionText (String) - The text to be used as the auto completion result. This is the value sent to the command.
  • listItemText (String) - The text to be displayed in a list, such as when the user presses Ctrl+Space. This is used for display only and is not passed to the command when selected.
  • resultType (CompletionResultType) - The type of completion result.
  • toolTip (String) - The text for the tooltip with details to be displayed about the object. This is visible when the user selects an item after pressing Ctrl+Space.

So it seems like Powershell can fit within rust-driven completions and provide the full feature set.

@MrJerB MrJerB linked a pull request Feb 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator E-easy Call for participation: Experience needed to fix: Easy / not much E-help-wanted Call for participation: Help is requested to fix this issue. 💸 $20
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants