Skip to content

Change of alias does not affect argumentcompleter #12285

@an-dr-eas-k

Description

@an-dr-eas-k

Steps to reproduce

Simple Steps:

Remove-Alias "cd"
get-Command "cd" # -> error, remove-alias was successful
cd <ctrl-space> # still shows completions

Enhanced Steps:

Remove-Alias "cd"
Function Invoke-CdAlternative {
	[cmdletbinding()]
	param(
		[string]$ToPrint
	)
	Write-Host "cdAlternative print argument: $($ToPrint)"
}

Register-ArgumentCompleter -CommandName Invoke-CdAlternative -ParameterName ToPrint -ScriptBlock {
	"foo", "bar" `
	| ForEach-Object { 
		[System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)
	}
}

Invoke-CdAlternative <ctrl-space> # successfully extends arguments
new-alias -name "cd" -Value "Invoke-CdAlternative"
cd <ctrl-space> # still shows completions for original cd alias
# on the other hand
new-alias -name "mycdalternative" -Value "Invoke-CdAlternative"
mycdalternative <ctrl-space> # shows the defined completions for invoke-cdalternative

Expected behavior

from Simple Steps

cd <ctrl-space> # shows default completions, all files in current folder?

from Enhanced Steps

cd <ctrl-space> # shows completions from ArgumentCompleter like the following does:
mycdalternative <ctrl-space>

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Interactive-IntelliSensetab completion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions