-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Closed
Copy link
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Interactive-IntelliSensetab completiontab completion
Description
When [System.Management.Automation.CommandCompletion]::CompleteInput is provided a ScriptBlock or AST that has a definition of the command to be completed in it the ArgumentCompleters that are registered in the PowerShell instance are ignored.
This issue is mostly visible when an editor(Visual Studio Code) leverages the CompleteInput to provide Intellisense(As seen in PowerShell/vscode-powershell#2162 ).
@powershell/powershell I am currently working on a fix for this and will submit a PullRequest if deemed valid.
Steps to reproduce
$script = @'
function Test-Completion {
param (
[String]$TestVal
)
}
[scriptblock]$completer = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
@('Val1','Val2','Val3')
}
Register-ArgumentCompleter -CommandName Test-Completion -ParameterName TestVal -ScriptBlock $completer
Test-Completion -TestVal
'@
$scriptBl = {
function Test-Completion {
param (
[String]$TestVal
)
}
[scriptblock]$completer = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
@('Val1', 'Val2', 'Val3')
}
Register-ArgumentCompleter -CommandName Test-Completion -ParameterName TestVal -ScriptBlock $completer
}
$pwsh = [PowerShell]::Create()
$pwsh.AddScript($scriptBl)
$pwsh.Invoke()
([System.Management.Automation.CommandCompletion]::CompleteInput($script, $script.Length, $null, $pwsh)).CompletionMatchesExpected behavior
CompletionText ListItemText ResultType ToolTip
-------------- ------------ ---------- -------
Val1 Val1 Text Val1
Val2 Val2 Text Val2
Val3 Val3 Text Val3
Actual behavior
List of files from my home directory
Environment data
Name Value
---- -----
PSVersion 6.2.2
PSEdition Core
GitCommitId 6.2.2
OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SeeminglyScience and DarkLite1
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Interactive-IntelliSensetab completiontab completion