Repository navigation
Closed
Description
Case 1: several modules each have a command with the same name (by coincidence)
Case 2: several top-level modules reference the same base module (e.g. having it as NestedModules with CmdletsToExport = '*')
In both cases tab-complete for such command fails and PS offers several instances of command with the same name which does not make sense from autocomplete point of view.
For example:
PS /home/pi> Test-TabCompl #press Tab here
Test-TabCompletion Test-TabCompletion Test-TabCompletion Test-TabCompletion It looks like a new 'instance' in the list is getting added after according module is imported.
Also this list seems to be saved across PS sessions, so if at least 2 modules with the same command were ever imported - the tab-completion for the command will be broken forever.
Steps to reproduce
- Create several copies of the same module, rename the copies;
- Import each copy of the module;
- optionally, can exit PS here and start a new one;
- Try to tab-complete a command from the module.
PS /home/pi> Get-Module -ListAvailable
Directory: /usr/local/share/powershell/Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
#...
Manifest 0.1.1 TestTabCompletion
Manifest 0.1.1 TestTabCompletion2
Manifest 0.1.1 TestTabCompletion3
Manifest 0.1.1 TestTabCompletion4
#...
PS /home/pi> ipmo TestTabCompletion
PS /home/pi> ipmo TestTabCompletion2
PS /home/pi> ipmo TestTabCompletion3
PS /home/pi> ipmo TestTabCompletion4
PS /home/pi> Test-TabComple # pressed Tab here
Test-TabCompletion Test-TabCompletion Test-TabCompletion Test-TabCompletion
PS /home/pi> exit
pi@raspberrypi:~ $ sudo ./PS610P2/pwsh
PowerShell v6.1.0-preview.2
Copyright (c) Microsoft Corporation. All rights reserved.
PS /home/pi> Test-TabComple # pressed Tab here
Test-TabCompletion Test-TabCompletion Test-TabCompletion Test-TabCompletionExpected behavior
Tab-completion on the command should succeed.
Actual behavior
Tab-completion for command fails.
Environment data
Name Value
---- -----
PSVersion 6.1.0-preview.2
PSEdition Core
GitCommitId v6.1.0-preview.2
OS Linux 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Activity
SteveL-MSFT commentedon Apr 29, 2018
In the case where there are duplicates, we should see if we can provide the fully qualified cmdlet path with the module prefix
lzybkr commentedon Apr 29, 2018
Try PSReadLine 2.0.0-beta1 - I think the experience is improved.
Jaykul commentedon Sep 15, 2023
Fwiw, I think this is long fixed -- except that I would love to convert this issue into a request for the fix that Steve Lee (@SteveL-MSFT) proposed.
MartinGC94 commentedon Feb 19, 2024
Joel Bennett (@Jaykul) It hasn't actually been fixed but PSReadLine added a workaround that deduplicates completion entries with the same list item text so it's not something users usually encounter. I've made a fix for this that does what Steve suggested.
Jaykul commentedon Dec 16, 2024
It would be silly to close an issue with an open PR....
microsoft-github-policy-service commentedon Mar 4, 2025
📣 Hey Andrew (@anmenaga), how did we do? We would love to hear your feedback with the link below! 🗣️
🔗 https://aka.ms/PSRepoFeedback