KEMBAR78
Tab-completion fails for commands with the same name from different modules · Issue #6765 · PowerShell/PowerShell · GitHub
Skip to content

Tab-completion fails for commands with the same name from different modules #6765

@anmenaga

Description

@anmenaga

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

  1. Create several copies of the same module, rename the copies;
  2. Import each copy of the module;
  3. optionally, can exit PS here and start a new one;
  4. 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-TabCompletion

Expected 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions