Skip to content
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

Console.ReadKey behaves differently in .NET 6 comparing to .NET 5 when TERM is set to rxvt #63387

Closed
Tracked by #64487
daxian-dbw opened this issue Jan 5, 2022 · 4 comments · Fixed by #72193
Closed
Tracked by #64487

Comments

@daxian-dbw
Copy link
Contributor

daxian-dbw commented Jan 5, 2022

Description

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:

image

However, in .NET 6, the the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:

image


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

  1. Run export TERM=rxvt
  2. Start PowerShell 7.2.0 or 7.2.1
  3. 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

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.Console untriaged New issue has not been triaged by the area owner labels Jan 5, 2022
@ghost
Copy link

ghost commented Jan 5, 2022

Tagging subscribers to this area: @dotnet/area-system-console
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

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:

image

However, in .NET 6, the the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:

image


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

  1. Run export TERM=rxvt
  2. Start PowerShell 7.2.0 or 7.2.1
  3. 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

Author: daxian-dbw
Assignees: -
Labels:

area-System.Console, untriaged

Milestone: -

@B-Art
Copy link

B-Art commented Jan 13, 2022

Description

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:

image

However, in .NET 6, the the ConsoleKeyInfo returned for LeftArrow has Control and Shift modifiers specified, as shown below:

image

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

  1. Run export TERM=rxvt
  2. Start PowerShell 7.2.0 or 7.2.1
  3. 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.

@daxian-dbw
Copy link
Contributor Author

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

@maxim-lobanov
Copy link

Any updates on this issue? It causes issues in PowerShell Core 7.2 because of update to .NET 6.

@jeffhandley jeffhandley added this to the 7.0.0 milestone May 30, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 30, 2022
@adamsitnik adamsitnik self-assigned this Jul 14, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 14, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 1, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants