-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Allow CompleteInput to return results from ArgumentCompleter when AST or Script has matching function definition #10574
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
Allow CompleteInput to return results from ArgumentCompleter when AST or Script has matching function definition #10574
Conversation
|
I'm unsure what would cause the test to fail after simply changing a spacing issue. Test prior to spacing issue: https://powershell.visualstudio.com/PowerShell/_build/results?buildId=32680 Test after spacing issue: https://powershell.visualstudio.com/PowerShell/_build/results?buildId=32688 |
iSazonov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor comment.
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
|
@TylerLeonhardt for impact on vscode-powershell @daxian-dbw - please review this change. |
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
| } | ||
| $pwsh = [PowerShell]::Create() | ||
| $pwsh.AddScript($scriptBl) | ||
| $pwsh.Invoke() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right. After invoking, Test-Completion would already been defined, and it's not the scenario you are aiming at -- AST or Script has matching function definition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of this is as follows:
The script block is executed to define the Test-Completion function and argument completer in the runspace.(As the runspace should provide the registered argument completers when in an editor).
From there, we are using the $script variable for completion input(Similar to how VSCode utilizes CompleteInput) as the issue arises when the function is defined in the $script block being passed to CompleteInput
|
@daxian-dbw can you re-review? |
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: Robert Holt <rjmholt@gmail.com>
daxian-dbw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM assuming the comment is addressed.
src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs
Outdated
Show resolved
Hide resolved
…letionCompleters.cs Co-Authored-By: Dongbo Wang <dongbow@microsoft.com>
|
@M1kep Thank you for your contribution! |
|
🎉 Handy links: |
PR Summary
Fix #10567
This PR adds a check in NativeCommandArgumentCompletion to retrieve the commandName from the CommandAST if the commandName passed is null.
PR Context
When
[System.Management.Automation.CommandCompletion]::CompleteInputis provided aScriptBlockorASTthat contains a definition of the function to be completed while there is a registeredArgumentCompleterfor the function, theArgumentCompleteris ignored.This issue is visible when an editor leverages the CompleteInput to provide Intellisense(PowerShell/vscode-powershell#2162 ).
The impact to editors is that completion will be returned in such a way that better matches the terminal experience.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.