diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-28 15:26:17 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 830e936da4aca7ea802a6a862fa40c0086defd2f (patch) | |
| tree | 8f2b76129f35fc27263dc975cfb61ac8b4024ea2 /src/exec.zig | |
| parent | d0b4e65eeaf71c8215cda347e7546f3abc07b25b (diff) | |
| download | pardes-830e936da4aca7ea802a6a862fa40c0086defd2f.tar.gz pardes-830e936da4aca7ea802a6a862fa40c0086defd2f.zip | |
A command of several lines keeps its pane's tag to one row, and the tag never panics on a longer prefix
A two-line exec made a command pane whose tag prefix held the line's newline,
so the tag ran to a second row and tagTintRange sliced its first row past its
end: panic. acme runs a multi-line selection as one command, and so does
pardes; the tag now shows the line's first row, cut at a character's start,
and '...', tagTintRange stays inside the row it is given, and the '% line'
echo turns the line's newlines into the terminal's, so it does not
staircase.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/exec.zig b/src/exec.zig index 1b82d2a8..84a0ad5f 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -534,9 +534,14 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize { // shown, then a soft reset (DECSTR) for the rest. if (panes.Terminal.onAlternateScreen(pane)) panes.Terminal.feedOutput(p, pane, "\x1b[?1049l"); panes.Terminal.feedOutput(p, pane, "\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[?25h\x1b[!p"); - var buf: [command_max + 8]u8 = undefined; - const lead = if (panes.Terminal.gridCursor(pane).x != 0) "\r\n" else ""; - panes.Terminal.feedOutput(p, pane, std.fmt.bufPrint(&buf, "{s}% {s}\r\n", .{ lead, line }) catch "%\r\n"); + // The line as it runs, its newlines the terminal's, so a multi-line + // command does not staircase. + var buf: [2 * command_max + 8]u8 = undefined; + var w = std.Io.Writer.fixed(&buf); + w.writeAll(if (panes.Terminal.gridCursor(pane).x != 0) "\r\n% " else "% ") catch {}; + for (line) |c| (if (c == '\n') w.writeAll("\r\n") else w.writeByte(c)) catch {}; + w.writeAll("\r\n") catch {}; + panes.Terminal.feedOutput(p, pane, w.buffered()); p.emit(.{ .spawn = .{ .pane = @intCast(id), .serial = pane.serial, .cwd = .from(pane.cwdSlice()) } }); noteRun(p, pane, "run", line); return id; |
