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/body_layer.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/body_layer.zig')
| -rw-r--r-- | src/body_layer.zig | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/body_layer.zig b/src/body_layer.zig index c8e229c4..42b9c082 100644 --- a/src/body_layer.zig +++ b/src/body_layer.zig @@ -674,7 +674,8 @@ pub fn paintHeaders(p: *Pardes) !void { fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { lo: usize, hi: usize } { if (pane.isTerminal()) { - var words = std.mem.tokenizeAny(u8, tag[prefix_len..], " \t\r\n"); + // `tag` is the first row; a prefix longer than it ran to a second. + var words = std.mem.tokenizeAny(u8, tag[@min(prefix_len, tag.len)..], " \t\r\n"); while (words.next()) |word| { if (!std.mem.eql(u8, word, "Tty") and !std.mem.startsWith(u8, word, "Tty+")) continue; const lo = @intFromPtr(word.ptr) - @intFromPtr(tag.ptr); @@ -687,7 +688,7 @@ fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { if (pane.prompt == .name) pane.input.own orelse file.path else file.path else if (pane.image) |state| blk: { // Image tags put renderer controls before the path. - start = std.mem.lastIndexOf(u8, tag[0..prefix_len], state.path) orelse return null; + start = std.mem.lastIndexOf(u8, tag[0..@min(prefix_len, tag.len)], state.path) orelse return null; break :blk state.path; } else if (comptime pdf_enabled) blk: { break :blk if (pane.pdf) |state| state.path else return null; |
