diff --git a/src/terminal/stream_readonly.zig b/src/terminal/stream_readonly.zig index 9ffe617bd..87b0d9788 100644 --- a/src/terminal/stream_readonly.zig +++ b/src/terminal/stream_readonly.zig @@ -213,9 +213,22 @@ pub const Handler = struct { self: *Handler, cmd: Action.SemanticPrompt, ) !void { - try self.terminal.semanticPrompt(cmd); - switch (cmd.action) { + .fresh_line_new_prompt => { + const kind = cmd.readOption(.prompt_kind) orelse .initial; + switch (kind) { + .initial, .right => { + self.terminal.markSemanticPrompt(.prompt); + if (cmd.readOption(.redraw)) |redraw| { + self.terminal.flags.shell_redraws_prompt = redraw; + } + }, + .continuation, .secondary => { + self.terminal.markSemanticPrompt(.prompt_continuation); + }, + } + }, + .end_prompt_start_input => self.terminal.markSemanticPrompt(.input), .end_input_start_output => self.terminal.markSemanticPrompt(.command), .end_command => self.terminal.screens.active.cursor.page_row.semantic_prompt = .input, @@ -226,14 +239,12 @@ pub const Handler = struct { // though we should handle them eventually. .end_prompt_start_input_terminate_eol, .new_command, + .fresh_line, .prompt_start, => {}, - - // Handled by the new action above - .fresh_line, - .fresh_line_new_prompt, - => {}, } + + try self.terminal.semanticPrompt(cmd); } fn setMode(self: *Handler, mode: modes.Mode, enabled: bool) !void { diff --git a/src/termio/stream_handler.zig b/src/termio/stream_handler.zig index 63094b106..b725649f1 100644 --- a/src/termio/stream_handler.zig +++ b/src/termio/stream_handler.zig @@ -320,7 +320,7 @@ pub const StreamHandler = struct { .progress_report => self.progressReport(value), .start_hyperlink => try self.startHyperlink(value.uri, value.id), .clipboard_contents => try self.clipboardContents(value.kind, value.data), - .semantic_prompt => self.semanticPrompt(value), + .semantic_prompt => try self.semanticPrompt(value), .mouse_shape => try self.setMouseShape(value), .configure_charset => self.configureCharset(value.slot, value.charset), .set_attribute => { @@ -1069,7 +1069,7 @@ pub const StreamHandler = struct { fn semanticPrompt( self: *StreamHandler, cmd: Stream.Action.SemanticPrompt, - ) void { + ) !void { switch (cmd.action) { .fresh_line_new_prompt => { const kind = cmd.readOption(.prompt_kind) orelse .initial; @@ -1113,6 +1113,10 @@ pub const StreamHandler = struct { .prompt_start, => {}, } + + // We do this last so failures are still processed correctly + // above. + try self.terminal.semanticPrompt(cmd); } fn reportPwd(self: *StreamHandler, url: []const u8) !void {