Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way to handle completion options #18963

Open
MartinGC94 opened this issue Jan 17, 2023 · 6 comments
Open

Better way to handle completion options #18963

MartinGC94 opened this issue Jan 17, 2023 · 6 comments
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@MartinGC94
Copy link
Contributor

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.

@MartinGC94 MartinGC94 added Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. labels Jan 17, 2023
@mklement0
Copy link
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)

@Andrew74L
Copy link

Andrew74L commented Jan 17, 2023

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

@mklement0
Copy link
Contributor

mklement0 commented Jan 17, 2023

@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).

@Andrew74L
Copy link

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

Thanks Michael

@MartinGC94
Copy link
Contributor Author

@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.

@mklement0
Copy link
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.

@daxian-dbw daxian-dbw added the WG-Engine core PowerShell engine, interpreter, and runtime label Jan 27, 2023
@ghost ghost added the In-PR Indicates that a PR is out for the issue label Apr 15, 2023
@ghost ghost removed the In-PR Indicates that a PR is out for the issue label Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants