Make `ForwardChar` configurable to accept whole suggestion or the next word of it
See original GitHub issueLoving new the suggested line - just on quite small problem, and I half expect the answer to be “We know, we’re working on it”, but I couldn’t see it in the open issues.
Environment
PS version: 7.0.1
PSReadline version: 2.1.0-beta2
os: 10.0.18362.1 (WinBuild.160101.0800)
PS file version: 7.0.1.0
HostName: ConsoleHost (Windows Terminal)
BufferWidth: 172
BufferHeight: 39
I don’t think this is version dependent - apart from needing this version of PSReadLine,
Steps to reproduce
-
Start Powershell (7) and allow PSRL 2.1.0 beta 2 to load normally, then run
Set-PSReadLineOption -PredictionSource History
-
Start typing a line from the history and see that it is suggested. Press right arrow to accept the line and then us left and right to move forwards and backwards along the line. Run or escape from the command.
-
Run
Get-PSReadLineKeyHandler | where function -Match "accept"
AcceptSuggestion and AcceptNextSuggestionWord are not listed -
run
Get-PSReadLineKeyHandler | where key -Match "rightarrow"
only the normal cursor movements are listed. -
I would like right arrow to be accept next word and ctrl+rightarrow or end to be accept all so I run
set-PSReadLineKeyHandler -Function AcceptNextSuggestionWord -Chord RightArrow
set-PSReadLineKeyHandler -Function AcceptSuggestion -Chord ctrl+RightArrow
-
Run
Get-PSReadLineKeyHandler | where Key -Match "rightarrow"
again these keys have lost their normal behavior -
Verify that accept suggestion by work or whole line works, select left works, but select right doesn’t
Expected behavior
A key can work inside and outside “suggestion” mode (as with the default right arrow.).
Actual behavior
It can’t
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Excellent , thank you.
Accept next suggestion word
functionality does not seem to be linked toForwardWord
, so I have gone back to the default of right arrow accepting the line, with a version of your example to make ctrl+right workThank you 🙏, your code snippet script block helped me a lot, I used it like this: