question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: support inline previews of tab completions

See original GitHub issue

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 <kbd>Tab</kbd> 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 <kbd>Tab</kbd> 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 <kbd>Tab</kbd> 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 <kbd>Tab</kbd>.

A challenge is how to handle transitioning to reviewing all possible completions at a given point, given that pressing <kbd>Tab</kbd> 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 <kbd>Tab</kbd> 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 <kbd>Ctrl + Tab</kbd>could 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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mklement0commented, Jun 29, 2022

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

1reaction
TBBlecommented, 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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a completion plugin with inline preview? : r/vim
Is there a completion plugin that shows Vim's next completion suggestion inline, and writes it on <Tab> ? Every completion tool I've found...
Read more >
Support Interaction With Suggest Widget · Issue #129495 · ...
First point, in VS Win there's italicized text to preview the selected item from intellisense list, and normal case for whole line completions....
Read more >
IntelliSense in Visual Studio Code
The editor supports "tab completion" which inserts the best matching completion when pressing Tab. This works regardless of the suggest widget showing or...
Read more >
Type less, code more with IntelliCode completions
IntelliCode now predicts the next chunk of code based on your current context, and presents it as an inline suggestion to the right...
Read more >
Emacs auto-complete: don't trigger on RET in inline ...
I type the first few letters e.g. "del" which get immediately auto-completed inline to "delete". If I wanted to type "delete" I hit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found