Skip to content

feat(input): smart Ctrl+C — copy selection or send SIGINT#78

Open
roramirez wants to merge 1 commit into
mainfrom
feat/smart-copy-ctrl-c
Open

feat(input): smart Ctrl+C — copy selection or send SIGINT#78
roramirez wants to merge 1 commit into
mainfrom
feat/smart-copy-ctrl-c

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

Ctrl+C now copies only when there is a real (anchored) selection; in every other case it sends SIGINT (0x03) to the PTY. Previously Ctrl+C mapped to Action::Copy for any Visual mode — including un-anchored navigation, where do_visual_copy no-ops — so the keypress was silently swallowed instead of interrupting the running program.

Changes

  • src/input/keybindings.rs: extract ctrl_c_action(mode) — returns Action::Copy only for InputMode::Visual { anchored: true, .. }, otherwise Action::SendToPty(vec![3]) (SIGINT). Wired into handle_ctrl_only.
  • src/input/keybindings_test.rs: cover Ctrl+C in Insert, Normal, anchored Visual (copy), un-anchored Visual (SIGINT, not no-op), and Ctrl+Shift+C / Ctrl+Alt+C (no regression to Copy).
  • CHANGELOG.md, doc/SPEC.md, README.md: document the new Ctrl+C behavior.

How to test

  • cargo test — all tests pass (1221 passed).
  • Manually: in a running mmterm, with no selection press Ctrl+C during a long-running command and confirm it interrupts (SIGINT); enter Visual mode, anchor a selection with v, press Ctrl+C and confirm it copies to the clipboard and returns to Insert.

Ctrl+C previously mapped to Action::Copy for any Visual mode, including
un-anchored navigation where do_visual_copy no-ops, swallowing the key.
Now Ctrl+C copies only when there is a real (anchored) selection and
sends SIGINT (0x03) in every other case (Insert, Normal, un-anchored
Visual).
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.

1 participant