Skip to content

fix-ctrl-c-double-exit-windows#86

Merged
cc-claws merged 3 commits into
mainfrom
fix/ctrl-c-double-exit
Jun 27, 2026
Merged

fix-ctrl-c-double-exit-windows#86
cc-claws merged 3 commits into
mainfrom
fix/ctrl-c-double-exit

Conversation

@cc-claws

Copy link
Copy Markdown
Owner

问题

Windows Terminal (ConPTY) 下按一次 Ctrl+C 偶发直接退出程序。

根因

ctrl_handler 收到 CTRL_C_EVENT 时注入 KeyDown + KeyUp 事件对。但 ConPTY 下原始 KEY_EVENT 可能残留在输入缓冲区中,crossterm 读到两个 KeyDown 事件(间隔约 0-1ms),直接触发 quit-pending → Quit。

修复

handle_ctrl_c 中加 100ms 防抖:quit_pending_since 设置后 100ms 内的重复事件视为同一次按键,忽略。不影响正常双击退出(人类间隔 200ms+)。

改动

  • peri-tui/src/event/keyboard/normal_keys.rshandle_ctrl_c 增加 100ms 最小间隔检查
  • peri-tui/src/event/keyboard.rs — 端到端测试适配防抖间隔

Fixes #85

cc-claws and others added 3 commits June 27, 2026 16:36
…icate events

Windows Terminal (ConPTY) may deliver two KeyDown events for a single
Ctrl+C press (native KEY_EVENT + ctrl_handler injected event). Without
debounce, both events reach handle_ctrl_c within ~0-1ms, causing the
quit-pending logic to trigger Quit on a single keypress.

Added a 100ms minimum interval check: if quit_pending_since was set
less than 100ms ago, treat the event as a duplicate and ignore it.

Fixes #85

Co-Authored-By: mimo-v2.5-pro <XiaomiMiMo@cc-code>
lines[N] 硬编码索引在 persist hint 附加行后错位,改用 contains 检查。
@cc-claws cc-claws merged commit 2e94e12 into main Jun 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix-ctrl-c-double-exit

1 participant