From a87c68d49aa1f3a08c8173dbd7744e68f8af4d30 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 9 Jun 2025 06:51:14 -0700 Subject: [PATCH] termio: unconditionally show "process exited" message We previously only showed this message if the user had `wait-after-command` set to true, since if its false the surface would close anyways. With the latest undo feature on macOS, this is no longer the case; a exited process can be undone and reopened. I considered disallowing undoing an exited surface, but I think there is value in being able to go back and recapture output in scrollback if you wanted to. --- src/termio/Exec.zig | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 23c626879..317ad13b4 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -418,25 +418,27 @@ fn processExitCommon(td: *termio.Termio.ThreadData, exit_code: u32) void { return; } + // We output a message so that the user knows whats going on and + // doesn't think their terminal just froze. We show this unconditionally + // on close even if `wait_after_command` is false and the surface closes + // immediately because if a user does an `undo` to restore a closed + // surface then they will see this message and know the process has + // completed. + terminal: { + td.renderer_state.mutex.lock(); + defer td.renderer_state.mutex.unlock(); + const t = td.renderer_state.terminal; + t.carriageReturn(); + t.linefeed() catch break :terminal; + t.printString("Process exited. Press any key to close the terminal.") catch + break :terminal; + t.modes.set(.cursor_visible, false); + } + // If we're purposely waiting then we just return since the process // exited flag is set to true. This allows the terminal window to remain // open. - if (execdata.wait_after_command) { - // We output a message so that the user knows whats going on and - // doesn't think their terminal just froze. - terminal: { - td.renderer_state.mutex.lock(); - defer td.renderer_state.mutex.unlock(); - const t = td.renderer_state.terminal; - t.carriageReturn(); - t.linefeed() catch break :terminal; - t.printString("Process exited. Press any key to close the terminal.") catch - break :terminal; - t.modes.set(.cursor_visible, false); - } - - return; - } + if (execdata.wait_after_command) return; // Notify our surface we want to close _ = td.surface_mailbox.push(.{