fix(tui/input): drop Release events when keyboard enhancement flags unsupported to prevent double character echo on Windows\n\nWindows terminals (e.g., CMD, PowerShell, Windows Terminal, Git Bash/MinTTY) may emit Press+Release without enhancement flags. Our previous normalization coerced all events to Press, turning Press+Release into two Press events and doubling typed characters.\n\nChange: When enhancement flags are not supported, ignore Release events and keep Press/Repeat semantics.\n\nFixes #40

This commit is contained in:
James Peter
2025-09-06 10:14:51 +10:00
parent aaae531e8c
commit 9e6b1945f3
+7 -2
View File
@@ -416,9 +416,14 @@ impl App<'_> {
if self.timing_enabled { self.timing.on_key(); }
// On terminals that do not support keyboard enhancement flags
// (notably some Windows Git Bash/mintty setups), crossterm may
// report only Release events. Normalize such events to Press so
// keys register consistently.
// report only Release events for some keys. Previously we coerced
// all events to `Press`, which turned a `Press`+`Release` pair into
// two `Press` events and doubled character insertion on Windows.
//
// Fix: when enhancement flags are not supported, drop `Release`
// events entirely and keep `Press`/`Repeat` semantics.
if !self.enhanced_keys_supported {
if key_event.kind == KeyEventKind::Release { continue; }
key_event = KeyEvent::new(key_event.code, key_event.modifiers);
}
// Reset double‑Esc timer on any non‑Esc key