mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:32:32 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user