fix(windows): make Ctrl-C interrupt panes and multi-line paste arrive as one block - #17
Merged
Merged
Conversation
…nes spawn A process inherits its parent's ignore-Ctrl-C flag, and CREATE_NEW_PROCESS_GROUP in daemon::detach sets it outright, so every ConPTY pane inherited it. conhost still delivered the 0x03 byte — an idle prompt abandoned its line and looked wired up — but raised no CTRL_C_EVENT, leaving a running program uninterruptible.
The Windows console has no paste input record, so crossterm never emits Event::Paste there and a paste arrives as one key press per character — every \r submitting a line. Coalesce the already-queued burst into a synthetic event so the existing bracketed-paste path applies unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two Windows-only defects in terminal panes. Both were reproduced, root-caused against real evidence, and verified running.
Ctrl-C never interrupted a running program
ping 8.8.8.8in a pane could not be stopped. The input path was already correct —map_keyleaves Ctrl-C unmapped,encode_keyemits0x03,send_inputwrites and flushes.The cause is a console disposition: a process inherits its parent's ignore-Ctrl-C flag, and
daemon::detachpassesCREATE_NEW_PROCESS_GROUP, which sets that flag outright. Every ConPTY pane inherited it. conhost still delivered the0x03byte — an idle prompt abandoned its line, so it looked wired up — but raised noCTRL_C_EVENT.Verified with a portable-pty probe: with the flag set,
pingsurvives0x03; afterSetConsoleCtrlHandler(NULL, FALSE), the same byte produces^Cand kills it.The clear lands in
run_daemon, not the TUI:attachowns no hub and only forwards keystrokes over the socket, so the daemon is the ConPTY parent.Multi-line paste split into one submission per line
crossterm's Windows event source produces only Key/Mouse/WindowBufferSize/Focus records —
Event::Pastenever fires, soEnableBracketedPasteis a no-op there and a paste arrives as one key press per character.input::burstcoalesces the burst into a syntheticEvent::Paste, reusing the existing bracketed-paste path unchanged. Two details came out of instrumented runs rather than reasoning:\r, not\n. Terminals normalise paste line breaks to CR;\nis dropped by some readers, collapsing the lines.The classifier is deliberately narrow — every event a plain unmodified character or Enter press, and either Enter plus another character or more than 16 characters — because a false positive submits typed keys as a block. Anything else falls back to per-event dispatch in arrival order.
Verification
cargo fmt --all --check,cargo build,cargo clippy --all-targets --all-features -- -D warnings,cargo test(1457 passed). 10 new tests cover the classification rule.Confirmed by hand in a real pane:
pingstops on Ctrl-C, and a 7-line paste arrives as a single block with no loss. Unix behaviour is untouched — the Unix seam is a no-op and the burst call site is#[cfg(windows)].