You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Console.ReadKey behaves differently in .NET 6 comparing to .NET 5 when TERM is set to rxvt #63387
We got a report in PowerShell repo about "arrow keys not functioning properly in PowerShell 7.2 with rxvt terminals", see PowerShell/PowerShell#16606.
It turns out Console.ReadKey behaves differently in .NET 6 comparing to .NET 5 when TERM is set to rxvt.
In .NET 5, the ConsoleKeyInfo returned for LeftArrow doesn't has any modifiers, as shown below:
However, in .NET 6, the the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:
It's not like Console.ReadKey always work properly in .NET 5 with rxvt terminals, for example, Home returns Escape+H (it returns OH in .NET 6), and End returns Escape+F (it returns OF in .NET 6), instead of Home and End as expected.
But it's been reported that setting TERM=xterm would make Console.ReadKey work as expected with regard to arrow keys with rxvt terminals -- see PowerShell/PowerShell#16606 (comment).
So, are rxvt terminals really supported by .NET 5/6? If so, what configurations should be done to make it work properly with Console.ReadKey?
Reproduction Steps
Run export TERM=rxvt
Start PowerShell 7.2.0 or 7.2.1
Try using arrow keys to navigate the cursor position
Expected behavior
LeftArrow and RightArrow should move the cursor left and right; LeftArrow and RightArrow should go through history commands.
Actual behavior
Arrow keys are not working as expected. Home and End prints OH and OF respectively.
Regression?
Yes.
Known Workarounds
Setting TERM=xterm would make Console.ReadKey work as expected with rxvt terminals.
We got a report in PowerShell repo about "arrow keys not functioning properly in PowerShell 7.2 with rxvt terminals", see PowerShell/PowerShell#16606.
It turns out Console.ReadKey behaves differently in .NET 6 comparing to .NET 5 when TERM is set to rxvt. In .NET 5, the ConsoleKeyInfo returned for LeftArrow doesn't has any modifiers, as shown below:
However, in .NET 6, the the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:
It's not like Console.ReadKey always work properly in .NET 5 with rxvt terminals, for example, Home returns Escape+H (it returns OH in .NET 6), and End returns Escape+F (it returns OF in .NET 6), instead of Home and End as expected.
But it's been reported that setting TERM=xterm would make Console.ReadKey work as expected with rxvt terminals.
So, are rxvt terminals really supported by .NET 5/6? If so, what configurations should be done to make it work properly with Console.ReadKey?
Reproduction Steps
Run export TERM=rxvt
Start PowerShell 7.2.0 or 7.2.1
Try using arrow keys to navigate the cursor position
Expected behavior
LeftArrow and RightArrow should move the cursor left and right; LeftArrow and RightArrow should go through history commands.
Actual behavior
Arrow keys are not working as expected. Home and End prints OH and OF respectively.
Regression?
Yes.
Known Workarounds
Setting TERM=xterm would make Console.ReadKey work as expected with rxvt terminals.
Configuration
No response
Other information
No response
In expected behavior:
You mean up arrow ⬆️ and down arrow ⬇️ for going through history.
You mean up arrow ⬆️ and down arrow ⬇️ for going through history.
Yes, it was reported that arrow keys worked as expected after setting TERM=xterm. I have updated the PR description to make this more clear:
But it's been reported that setting TERM=xterm would make Console.ReadKey work as expected with regard to arrow keys with rxvt terminals -- see PowerShell/PowerShell#16606 (comment).
Activity
B-Art commentedon Jan 13, 2022
In expected behavior:
You mean up arrow ⬆️ and down arrow ⬇️ for going through history.
daxian-dbw commentedon Jan 13, 2022
Yes, it was reported that arrow keys worked as expected after setting
TERM=xterm. I have updated the PR description to make this more clear:maxim-lobanov commentedon Mar 24, 2022
Any updates on this issue? It causes issues in PowerShell Core 7.2 because of update to .NET 6.
Read up/down keys on *nix properly - fixes #11