Better way to handle completion options · Issue #18963 · PowerShell/PowerShell · GitHub
Skip to content

Better way to handle completion options #18963

Open

Description

@MartinGC94

Summary of the new feature / enhancement

There are several user requests to provide tab completion options for various things. Examples include:
#16747
#3118
#10064
#14337

Tab completion already includes a couple of options like [bool] RelativePaths and [bool]IgnoreHiddenShares but the current way to set such options is hard to discover and inconvenient to change on the fly.
For people that don't know, you need to modify the TabExpansion2 so both CompleteInput method calls use a hashtable with all the desired options set. There is an options parameter but if you try to set the default value there it gets ignored when you call TabExpansion2 with your tab key.

Proposed technical implementation details (optional)

Add a new variable similar to $PSStyle that contains all tabexpansion options, it could be called $PSTabExpansionOptions.
Another option would be to add 2 commands: Get-TabExpansionOption and Set-TabExpansionOption.

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    on Jan 17, 2023
  2. mklement0 commented on Jan 17, 2023

    @mklement0
    Contributor

    👍 re centralizing tab-completion customizations in principle, but surfacing them (publicly) in PowerShell itself strikes me as the wrong place; instead, they should be surfaced via PSReadLine or via PSES - see also: #18942 (comment)

  3. Andrew74L commented on Jan 17, 2023

    @Andrew74L

    Add a new variable similar to $PSStyle that contains all tabexpansion options, it could be called $PSTabExpansionOptions. Another option would be to add 2 commands: Get-TabExpansionOption and Set-TabExpansionOption.

    Is it conceivable we would ever get tab-completion for a subset of native commands? I find it slightly odd that Powershell cannot tab-complete for pwsh. Other candidates would be commands that cmdlets call down to, like the DISM cmdlets. If I use dism.exe, Powershell won't help by tab-completion, even though it knows (in a sense) how to. Hypothetically:
    Set-TabExpansionOption -KnownExecutables $true

  4. mklement0 commented on Jan 17, 2023

    @mklement0
    Contributor

    Andrew74L, providing tab-completion for an open-ended set of external CLIs is obviously impossible for PowerShell to provide itself (though you could argue that for pwsh itself it should indeed be built in).

    Third-party, community-supported projects are the solution - see the posh-cli module (repository is here).

  5. Andrew74L commented on Jan 17, 2023

    @Andrew74L

    Third-party, community-supported projects are the solution - see the posh-cli module (repository is here).

    Thanks Michael

  6. MartinGC94 commented on Jan 18, 2023

    @MartinGC94
    ContributorAuthor

    Michael Klement (@mklement0) The problem with that approach is that every time a new option is added every interactive host author needs to update their app separately, and for editors that are no longer maintained (like ISE) you just lose the ability to set new options.
    In the case of PSReadline it could also cause some confusion if people are running an older version of PowerShell with a new version of PSReadline and see a new feature that is unavailable to them.

  7. mklement0 commented on Jan 18, 2023

    @mklement0
    Contributor

    PSReadLine is (a) the module that provides the interactive command-line editing experience, and (b) is bundled with PowerShell.

    Yes, the fact that you can update PSReadLine independently of PowerShell is problematic (a problem that already affects Windows PowerShell with Set-PSReadLineOption -PredictionSource, for instance).

    But I think that would be outweighed by the confusion that controlling the interactive experience in two distinct places, with different syntax would invite.

  8. ghost added
    In-PRIndicates that a PR is out for the issue
    on Apr 15, 2023
  9. ghost removed
    In-PRIndicates that a PR is out for the issue
    on Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions