-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Fixed #5205: Ctrl+Alt+2 doesn't send ^[^@ #5272
Conversation
BTW I couldn't run tests locally, because I'm faced with the following error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty much okay with this, but let's see those test pass :)
src/terminal/input/terminalInput.cpp
Outdated
WORD TerminalInput::_ScanCodeFromVirtualKey(const WORD vkey) noexcept | ||
{ | ||
return LOWORD(MapVirtualKeyW(vkey, MAPVK_VK_TO_VSC)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part of me thinks we should move these helpers to some shared space, since this isn't the first time this has been written, but that's probably a better follow-up codehealth task.
if (ch == 0) | ||
{ | ||
// There are a few vkeys that MapVirtualKeyW() above turns into 0, | ||
// while TerminalInput is still capable of processing them. | ||
// The important ones are tested in DifferentModifiersTest/TerminalInputNullKeyTests. | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zadjii-msft In order for the tests to work again I disabled tests for certain Ctrl+Alt combinations as you can see here.
We could make the tests work if we pull in the ToUnicodeEx()
logic into this file as well. If we do that though we should probably really create a helper file that contains this function separately. 😄
On the other hand I personally kinda doubt that this if condition makes this unit test any worse, because to fix this unit test we have to basically add a identical copy of the TerminalInput::_CharacterFromAltCtrlKeyEvent
method.
And IMHO that way we'd just test for the current state of affairs of which OS methods we use instead for the actual results that we'd like to see for each character, you know? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea this is fine with me
@zadjii-msft Now the build bot is facing the same issue I had earlier:
What do? 😱 |
maybe re-queueing it will help. maybe there was a VS update. :/ |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this too!
src/terminal/input/terminalInput.cpp
Outdated
if (keyEvent.IsModifierPressed() && _searchWithModifier(keyEvent, senderFunc)) | ||
{ | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea moving this seems fine to me, it's not like the code that was before it was having any effect on this block, so it can life here just fine.
if (ch == 0) | ||
{ | ||
// There are a few vkeys that MapVirtualKeyW() above turns into 0, | ||
// while TerminalInput is still capable of processing them. | ||
// The important ones are tested in DifferentModifiersTest/TerminalInputNullKeyTests. | ||
continue; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea this is fine with me
@zadjii-msft I believe I made a mistake in this PR. I tested it again just now and Also there's the fact that |
@zadjii-msft I guess I can't figure out anymore how I originally fixed the issue. 😐 One quick question regarding this PR though: Should I revert my addition of
The current solution with But the downside to the What are your thoughts about this? |
I kinda forgot about this PR. 😅 I‘ll try to tackle this again soon. |
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
1 similar comment
Misspellings found, please review:
To accept these changes, run the following commands from this repository on this branch
✏️ Contributor please read thisBy default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
See the 🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉 🗜️ If you see a bunch of garbage and it relates to a binary-ish string, please add a file path to the File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did we never merge this before...?
Hello @zadjii-msft! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
🎉 Handy links: |
Summary of the Pull Request
Fixes #5205, by replacing another use of
MapVirtualKeyW
withToUnicodeEx
.The latter just seems to be much more consistent at translating key combinations in general.
In this particular case though it fixes the issue, because there's no differentiation in
MapVirtualKeyW
for whether it failed to return a character ('\0'
) or succeeded in turning^@
into'\0'
.ToUnicodeEx
on the other hand returns the success state separately from the translated character.PR Checklist
Detailed Description of the Pull Request / Additional comments
This PR changes the behavior of the
⚠️ ⚠️
Ctrl+Alt+Key
handling slightly:ToUnicodeEx
returns unshifted characters.For instance
Ctrl+Alt+a
is now turned into^[^a
. Due to how ASCII works this is essentially the same though because'A' & 0b11111
and'a' & 0b11111
are the same.Validation Steps Performed
showkey -a
Ctrl+Alt+Space
as well asCtrl+Alt+Shift+2
are turned into^[^@
Ctrl+Alt+Key
combination behave identical to the current master