[PR #4940] Fix C-M-z, C-M-x in Conpty #26046

Open
opened 2026-01-31 09:13:35 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4940

State: closed
Merged: Yes


Summary of the Pull Request

This PR ensures that Conpty properly treats ^[^Z and ^[^X as
Ctrl+Alt+z and Ctrl+Alt+x, instead of Ctrl+z
and Ctrl+x.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

^Z and ^X are special control characters, SUB and CAN. For the output state
machine, these characters are supposed to be executed from any state. However,
we shouldn't do this for the input engine. With the current behavior, these
characters are immediately executed regardless of what state we're in. That
means we end up synthesizing Ctrl+z/x for these characters. However,
for the InputStateMachine engine, when these characters are preceeded by ^[
(ESC), we want to treat them as Ctrl+Alt+z/x.

This just adds a check in StateMachine to see if we should immediately execute
these characters from any state, similar to many of the other exceptions we
already perform in the StateMachine for the input engine.

Validation Steps Performed

  • ran tests
  • checked showkey -a in gnome-terminal
  • checked showkey -a in conhost
  • checked showkey -a in vt pipeterm (conhost as a conpty terminal)
  • checked showkey -a in Windows Terminal
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4940 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This PR ensures that Conpty properly treats `^[^Z` and `^[^X` as <kbd>Ctrl+Alt+z</kbd> and <kbd>Ctrl+Alt+x</kbd>, instead of <kbd>Ctrl+z</kbd> and <kbd>Ctrl+x</kbd>. ## References ## PR Checklist * [x] Closes #4201 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments `^Z` and `^X` are special control characters, SUB and CAN. For the output state machine, these characters are supposed to be executed from _any_ state. However, we shouldn't do this for the input engine. With the current behavior, these characters are immediately executed regardless of what state we're in. That means we end up synthesizing <kbd>Ctrl+z/x</kbd> for these characters. However, for the InputStateMachine engine, when these characters are preceeded by `^[` (ESC), we want to treat them as <kbd>Ctrl+Alt+z/x</kbd>. This just adds a check in `StateMachine` to see if we should immediately execute these characters from any state, similar to many of the other exceptions we already perform in the StateMachine for the input engine. ## Validation Steps Performed * ran tests * checked `showkey -a` in gnome-terminal * checked `showkey -a` in conhost * checked `showkey -a` in vt pipeterm (conhost as a conpty terminal) * checked `showkey -a` in Windows Terminal
claunia added the pull-request label 2026-01-31 09:13:35 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#26046