aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-08-01 05:08:17 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-08-01 05:08:17 +0300
commit26a7bc860e4af516ef687d90b9f9dd2830f88d2a (patch)
treec8d2332222917b9fd4128609fb157729eace919c /src/platform
parentb76adc155d979705a353fd6dc87c702f9dfc6c22 (diff)
fix(windows): preserve semantic escape key taps
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/windows.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/platform/windows.rs b/src/platform/windows.rs
index 6cc642eb..f384ea02 100644
--- a/src/platform/windows.rs
+++ b/src/platform/windows.rs
@@ -76,6 +76,12 @@ pub(crate) fn encode_windows_conpty_fallback(key: &crate::input::TerminalKey) ->
record.unicode,
record.control_key_state,
)
+ } else if key.code == KeyCode::Esc
+ && key.modifiers.is_empty()
+ && key.kind == KeyEventKind::Press
+ && key.vt_bytes().is_none()
+ {
+ return Some(b"\x1b[27;1;27;1;0;1_\x1b[27;1;27;0;0;1_".to_vec());
} else if key.code == KeyCode::Enter && key.modifiers == KeyModifiers::SHIFT {
(13, 28, 13, 16)
} else {
@@ -1435,6 +1441,46 @@ mod tests {
}
#[test]
+ fn windows_conpty_native_encoder_preserves_semantic_escape_fallback() {
+ let escape = crate::input::TerminalKey::new(
+ crossterm::event::KeyCode::Esc,
+ crossterm::event::KeyModifiers::empty(),
+ );
+
+ assert_eq!(
+ super::encode_windows_conpty_fallback(&escape),
+ Some(b"\x1b[27;1;27;1;0;1_\x1b[27;1;27;0;0;1_".to_vec())
+ );
+ assert_eq!(
+ super::encode_windows_conpty_fallback(
+ &escape
+ .clone()
+ .with_kind(crossterm::event::KeyEventKind::Repeat),
+ ),
+ None
+ );
+ assert_eq!(
+ super::encode_windows_conpty_fallback(
+ &escape
+ .clone()
+ .with_kind(crossterm::event::KeyEventKind::Release),
+ ),
+ None
+ );
+ assert_eq!(
+ super::encode_windows_conpty_fallback(&escape.clone().with_vt_bytes(vec![27])),
+ None
+ );
+ assert_eq!(
+ super::encode_windows_conpty_fallback(&crate::input::TerminalKey::new(
+ crossterm::event::KeyCode::Esc,
+ crossterm::event::KeyModifiers::ALT,
+ ),),
+ None
+ );
+ }
+
+ #[test]
fn windows_conpty_native_encoder_preserves_semantic_shift_enter_fallback() {
let shift_enter = crate::input::TerminalKey::new(
crossterm::event::KeyCode::Enter,