8000 KeyChar should be preserved for Ctrl+Letter by adamsitnik · Pull Request #75853 · dotnet/runtime · GitHub
[go: up one dir, main page]

Skip to content

KeyChar should be preserved for Ctrl+Letter #75853

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

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

adamsitnik
Copy link
Member
@adamsitnik adamsitnik commented Sep 19, 2022

This PR restores the .NET 6 behavior for Ctrl+Letter key combinations, which is what Windows does as well.

It does so only when Alt key was not pressed at the same time:

Windows Terminal:

image

cmd.exe:

image

fixes #75795

@ghost
Copy link
ghost commented Sep 19, 2022

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

Issue Details

This PR restores the .NET 6 behavior for Ctrl+Letter key combinations, which is what Windows does as well.

fixes #75795

Author: adamsitnik
Assignees: -
Labels:

area-System.Console

Milestone: -

@adamsitnik
Copy link
Member Author

/backport to release/7.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/7.0-rc2: https://github.com/dotnet/runtime/actions/runs/3085454024

@danmoseley
Copy link
Member

Why was this case special? Can we think of any other possible similar special cases (or should we look for any) -- do we have good reason to believe this is the only bug of this sort?

@adamsitnik
Copy link
Member Author

Why was this case special?

When I was implementing the new key parser, I assumed that Ctrl+Letter should be mapped just to given Key=Letter with Modifier=Control because preserving the original key char seemed to have no value, as the key char does not map to an ascii character of given key.

Example: User presses Ctrl+A (no matter if Caps Lock is enabled or not) and the KeyChar is 1. 1 in ASCII is SOH: Start Of Heading.

I assumed it was Linux-specific thing, and just assigned default value to KeyChar. I was wrong, as it turned out that Windows also preserves the KeyChar for Ctrl+Letter combinations. I don't know why and what is the benefit of it.

Can we think of any other possible similar special cases (or should we look for any)

Yes, Ctrl+Alt+Letter and as I wrote in the description, I've ensured that for such cases we are consistent too (for them the KeyChar needs to be assigned to default value).

-- do we have good reason to believe this is the only bug of this sort?

No, because there are plenty of key combinations and since I was the only person who tested it so far, I was testing my own implementation and assumptions, which as we can see turned out to be wrong in some cases.

I am actually happy that PowerShell reported this bug as it means that they have performed objective testing.

Don't forget that we have introduced a new config switch and the users can always switch to .NET 6 parser.

@adamsitnik adamsitnik merged commit 4b8ab84 into dotnet:main Sep 20, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

On Linux, the KeyChar of the ConsoleKeyInfo returned from Ctrl+c becomes \0 with .NET 7-RC.1
4 participants
0