Skip to content

Suggestion: support inline previews of tab completions #741

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

Closed
mklement0 opened this issue Aug 5, 2018 · 8 comments
Closed

Suggestion: support inline previews of tab completions #741

mklement0 opened this issue Aug 5, 2018 · 8 comments
Labels

Comments

@mklement0
Copy link

Note: The suggested feature may have to be constrained to certain types of completions, and it is debatable whether it should be the default behavior or opt-in via a new option, but overall I think it would greatly streamline the tab-completion experience.

Imagine if PSReadLine showed you a preview of what the token you're currently typing would expand to if you pressed Tab at that moment; e.g.:

image

That is, having typed parameter-name prefix -Fo, PSReadLine would show you, via the differently colored - "rce" part, that if you pressed Tab at that moment you'd end up with -Force.

If the preview doesn't indicate the desired parameter, simply keep typing until the desired one is suggested; e.g., additionally type an l to make the preview show "lowSymlink" to inform you that pressing Tab then would complete to -FollowSymlink.

This makes for a very convenient experience if you know what exactly what completion you're looking for : just keep typing - without interruption - until you see what you want, then press Tab.

A challenge is how to handle transitioning to reviewing all possible completions at a given point, given that pressing Tab in this scenario would have to result in instant completion (whereas currently you can use it to cycle through the candidate completions).

  • If technically feasible, pressing Tab right after a completion would still be aware of what prefix was actually typed and would still allow cycling through the possible completions.

  • Alternatively / complementarily, a separate key chord such as Ctrl + Tabcould be used to show all possibly completions in a menu, via built-in function MenuComplete.


As an aside: If someone prefers the current tab-completion behavior in principle, but would like to show a menu of possible completions in case of ambiguity, they can add the following to your $PROFILE:

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

Environment data

PS version: 6.1.0-preview.4
PSReadline version: 2.0.0-beta2
os: 10.0.16299.15 (WinBuild.160101.0800)
PS file version: 6.1.0
@felixfbecker
Copy link

Duplicate of #687

@mklement0
Copy link
Author

Thanks, @felixfbecker - hadn't seen yours. Certainly closely related, but your suggestion is about completions from the history, whereas this one is about the standard, syntax-based tab completions.

Both behaviors are useful, but I'm unclear on if and how they could be rolled into a single feature: when would you choose which completion source?

@TBBle
Copy link

TBBle commented Jun 29, 2022

It appears that https://github.com/PowerShell/CompletionPredictor delivers this feature via Prediction. The default keys are different because it's Prediction (being fed from Completion) rather than Completion, but that does also resolve the question in #741 (comment), because you get suggestions from both history and plugins by default, and in the list view (but not inline, see #1945) it tells you where the prediction came from.

@mklement0

This comment was marked as resolved.

@daxian-dbw
Copy link
Member

The ask of this issue can be achieved by using the CompletionPredictor module along with PSReadLine 2.2+. Especially, the predictive intellisense feature is enabled by default in v2.2.6 release of PSReadLine.

Here is a GIF to show the asked behavior (using Windows edit mode and HistoryAndPlugin as the PredictionSource):

CompletionPredictor

Given this, I will mark the issue as fixed.

@daxian-dbw daxian-dbw removed this from the 2.1.0-Consider milestone Jun 29, 2022
@TBBle
Copy link

TBBle commented Jun 29, 2022

The plugin https://github.com/PowerShell/CompletionPredictor adds (If I understand correctly) "syntax-based completions". In PSReadLine 2.2.6, Set-PSReadLineOption -PredictionSource HistoryAndPlugin is the default, so installing and importing that module should be sufficient to resolve this ticket.

(And I can see that's happening in parallel as I comment)

@mklement0

This comment was marked as resolved.

@mklement0
Copy link
Author

One more thing, because it may not be obvious (should someone in the future stumble upon this thread): plugins (completer modules) must be imported explicitly into every session (via $PROFILE) - PSReadLine, at last as of v2.2.6, does not try to discover and load them automatically (for performance reasons, I presume).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants