diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 6e8d18ec8..2f87ae0d5 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -1025,6 +1025,10 @@ fn printWrap(self: *Terminal) !void { // Move to the next line try self.index(); self.screen.cursor.x = self.scrolling_region.left; + + // New line must inherit semantic prompt of the old line + const new_row = self.screen.getRow(.{ .active = self.screen.cursor.y }); + new_row.setSemanticPrompt(row.getSemanticPrompt()); } fn clearWideSpacerHead(self: *Terminal) void { @@ -2507,6 +2511,23 @@ test "Terminal: soft wrap" { } } +test "Terminal: soft wrap with semantic prompt" { + var t = try init(testing.allocator, 3, 80); + defer t.deinit(testing.allocator); + + t.markSemanticPrompt(.prompt); + for ("hello") |c| try t.print(c); + + { + const row = t.screen.getRow(.{ .active = 0 }); + try testing.expect(row.getSemanticPrompt() == .prompt); + } + { + const row = t.screen.getRow(.{ .active = 1 }); + try testing.expect(row.getSemanticPrompt() == .prompt); + } +} + test "Terminal: print writes to bottom if scrolled" { var t = try init(testing.allocator, 5, 2); defer t.deinit(testing.allocator);