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
Allow accepting suggestion with the EndOfLine key (End) if cursor is at the end of line #3705
Comments
Thanks for the issue @Jackenmen! You change change the |
I was asking for a change in the default behavior of the
This would make it act more like the
Right now, I use this custom key handler to do this: Set-PSReadLineKeyHandler -Key "End" `
-BriefDescription ForwardCharAndAcceptNextSuggestionWord `
-LongDescription "Move the cursor to the end of the current editing line or accept the suggestion if it's already there" `
-ScriptBlock {
param($key, $arg)
$line = $null
$cursor = $null
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
if ($cursor -lt $line.Length) {
[Microsoft.PowerShell.PSConsoleReadLine]::EndOfLine($key, $arg)
} else {
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptSuggestion($key, $arg)
}
} but as I described in the issue, I think that this would be a sensible default to have which is why I'm requesting it. Personally, I feel like it's a weird inconsistency considering that both the right arrow and the End key are used for cursor movement. |
The relevant functions: PSReadLine/PSReadLine/Movement.cs Lines 17 to 34 in 9e7b1fe
PSReadLine/PSReadLine/Movement.cs Lines 49 to 66 in 9e7b1fe
|
Prerequisites
Description of the new feature/enhancement
Currently, it is only possible to accept suggestions when at the end of line if the
ForwardChar
(right arrow) key is hit. I think it would also make sense to treat theEndOfLine
(End) key the same way. I know that this is how zsh-autosuggestions work, I haven't tested if fish autosuggestions also work like that but I feel like it's an intuitive behavior since you're trying to go to the end of the suggested line. I'm sure it is possible with a script block (I haven't yet looked into how but probably will soon) but I think that this would be a sensible default to have.Arguably, the End key makes more sense than the right arrow key, and the right arrow key could be used for accepting the next word but that's really just my opinion which doesn't really matter when there are already so many users that are used to this. + It is possible to change it with the provided
ForwardCharAndAcceptNextSuggestionWord
example.Proposed technical implementation details (optional)
No response
[Edited by @daxian-dbw] Added one upvote to represent the duplicate issue #3741
The text was updated successfully, but these errors were encountered: