Skip to content

fix: suspend with Ctrl-Z - #355

Open
HackAttack wants to merge 1 commit into
RivoLink:mainfrom
HackAttack:fix/ctrl-z
Open

HackAttack wants to merge 1 commit into
RivoLink:mainfrom
HackAttack:fix/ctrl-z

Conversation

@HackAttack

Copy link
Copy Markdown

Ctrl-Z does nothing in leaf: raw mode delivers it as a key press, so the shell's job control never sees it.

Handle Ctrl-Z as a key: leave the TUI through the same suspend/resume path the external editor already uses, stop the job, and redraw on fg. A job sent to the background with bg stays stopped until fg, because re-entering raw mode from the background stops it again.

This fixes #297 in a way that hopefully overcomes the objections of #296 by taking a smaller approach:

  • No signal handlers, no polling in the event loop, and no wrapper around the editor launch
  • Restoring the terminal reuses TerminalSession::suspend/resume, so there is no second copy of that logic

Ctrl-Z does nothing in leaf: raw mode delivers it as a key press, so the
shell's job control never sees it.

Handle Ctrl-Z as a key: leave the TUI through the same suspend/resume
path the external editor already uses, stop the job, and redraw on `fg`.
A job sent to the background with `bg` stays stopped until `fg`, because
re-entering raw mode from the background stops it again.
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.

feat: Suspend with Ctrl+Z on Unix terminals

1 participant