-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
TerminalControl handles ALT+NUMPAD input poorly #1401
Comments
Weird behavior in all terminals: Numpad on/off state changes the output
|
When the user enters Alt-123 it looks like we're doing this:
Powershell and bash (readline) interpret alt-number as "enter digit-argument mode." Digit argument mode usually means "repeat the first character N times" ... so this results in character We should definitely fix that. |
If someone (potentially inexperienced with this project) wants to debug this issue they might find the following line of interest: terminal/src/terminal/input/terminalInput.cpp Line 428 in 5dd1f8d
It's the one responsible for generating the escape codes. The following callback then sends these further to the shell: terminal/src/cascadia/TerminalCore/Terminal.cpp Lines 53 to 60 in 5dd1f8d
( I'm personally not entirely certain where the @ is coming from, but I suspect this is generated by the Operating System and sent as a WM_CHAR message to the application here: terminal/src/cascadia/TerminalControl/TermControl.cpp Lines 564 to 565 in 5dd1f8d
If I'm correct, then to go fully UNIXy we might want to prevent the OS from translating Alt+Numpad for us (however one would do that). Otherwise we should disable the call to |
## Summary of the Pull Request Alt-Numpad# input would be escaping each numkey before sending it through. This would result in some weird behavior, for example, in powershell, where the first alt-numpad# would start digit argument and once the user releases alt, a character is sent through and digit argument would repeat that character X times. To resolve this, we simply need to ignore KeyDowns where Alt is held and a Numpad# is pressed. Once Alt is released, we'll receive a character through `TSFInputControl`, not `TermControl::CharacterHandler`. It seems that the `CoreTextEditContext` in `TSFInputControl` intercepts the character before it gets to `TermControl`. TSF will then send the received character through as normal. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1401 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Testing various combinations of Alt-Numpad# consistently sends through only one instance of the expected symbols.
## Summary of the Pull Request Alt-Numpad# input would be escaping each numkey before sending it through. This would result in some weird behavior, for example, in powershell, where the first alt-numpad# would start digit argument and once the user releases alt, a character is sent through and digit argument would repeat that character X times. To resolve this, we simply need to ignore KeyDowns where Alt is held and a Numpad# is pressed. Once Alt is released, we'll receive a character through `TSFInputControl`, not `TermControl::CharacterHandler`. It seems that the `CoreTextEditContext` in `TSFInputControl` intercepts the character before it gets to `TermControl`. TSF will then send the received character through as normal. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1401 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Testing various combinations of Alt-Numpad# consistently sends through only one instance of the expected symbols. (cherry picked from commit cddac25)
🎉This issue was addressed in #4965, which has now been successfully released as Handy links: |
plz, reopen @avdi @shanselman @timheuer @alecthegeek @atifaziz @leonMSFT @leoniDEV |
Sorry about it still happening @effolkronium! From your repro, it almost looks like your Terminal never got the PR that fixed the thing where digit-argument starts #4965. I tried to repro this on a bunch of my machines. A couple of them are running a version of Terminal that's further ahead, but I have a couple that are also running 0.10.781.0, and it's working fine for me (so that's a real head scratcher). 😢 I'm also asking the rest of the team to see if they can repro what you're seeing, and so far no luck, I can't get a reliable repro for what you're seeing. For now the only thing I can suggest is I'd like for you to try reinstalling Terminal if you get a chance (this is a wild guess that may or may not work). |
I think ALT worked well day or week ago for me. as i can see terminal got the update at the end of last month. So i think it was ok with this version some time I just re -installed the Terminal but the bug still reproduces. ^((( ... Also it doesn't work with update before current. Maybe some OS or third party app impact... I'll try to investigate a bit, maybe even debug the terminal by myself |
Well, ignoring VirtualKey::Number0 - VirtualKey::Number9 doesn't help it passes check but tab switch still no happening. could you suggest what i should debug or look to for fix ? |
dude, Alt NUMPAD input only works if you use the number pad. The numbers below the F keys aren’t the number pad. |
Man, it worked well all the time when I used this app in past. I have no numpud on my keyboard |
Correct me if I'm wrong, but... @effolkronium Unfortunately if that has ever worked it must've been a bug anyways. Entering Alt codes with regular number keys most definitely wasn't a feature. I'm not aware of Windows supporting Alt codes with regular number keys in the first place. Some keyboards with Fn keys support entering numeric keypad codes using the main keyboard. |
oK, so it works if i press alt+ctr+num. i think ticket should be closed |
@lhecker thanks for the excellent write up |
When the user enters Alt-123 it looks like we're doing this:
ESC
1
2
3
Powershell and bash (readline) interpret alt-number as "enter digit-argument mode." Digit argument mode usually means "repeat the first character N times" ... so this results in character
123
being added to the buffer 123 times.We should definitely fix that.
original content
Environment
Steps to reproduce
ALT
key~
)Expected behavior
a tilde (
~
) is insertedActual behavior
127 tildes are inserted
The same thing happens for all the versions of Powershell listed above
The text was updated successfully, but these errors were encountered: