Add ctrl+enter key binding for Linux#3983
Open
jborean93 wants to merge 1 commit intoPowerShell:masterfrom
Open
Add ctrl+enter key binding for Linux#3983jborean93 wants to merge 1 commit intoPowerShell:masterfrom
jborean93 wants to merge 1 commit intoPowerShell:masterfrom
Conversation
Adds the Ctrl+Enter key binding for Linux that defaults to AcceptLine. This allows PSReadLine to work by default on Linux terminals like Alacritty where a newline in a paste comes across as the Ctrl+Enter key.
|
Finally, I was looking for a fix for months. Added to my profile and haven't looked back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Adds the Ctrl+Enter key binding for Linux that defaults to AcceptLine. This allows PSReadLine to work by default on Linux terminals like Alacritty (in tmux) where a newline in a paste comes across as the Ctrl+Enter key. Not all terminals on Linux will send a newline in a paste as this key but some do. Having this key handler means that pasting a string with newlines is preserved properly rather than as
You can replicate how a newline was handled in a tty with a .NET application by running the following Python code on Linux
The output on PowerShell 7.4/.NET 8 is
{ "KeyChar": "\n", "Key": "Enter", "Modifiers": "Control" }.NET introduced a rewrite of
Console.ReadKey()in .NET 7 dotnet/runtime#72193 that changed how a\non a tty was handled. In the past this is what it returned{ "KeyChar": "\r", "Key": "Enter", "Modifiers": 0 }As there were no modifiers the
\rwas treated as a newline and so just worked.I'm unsure how you wish for me to test this, any guidance there would be appreciated.
PR Checklist
Microsoft Reviewers: Open in CodeFlow