diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 14:16:47 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 14:16:47 -0300 |
| commit | 89fb37907f34c0a55b85da44ea8f016b3e41081d (patch) | |
| tree | b3ca009b7fc6d714bb6691d53f496282b0a72188 /core | |
| parent | e6c384833912598d65c509f0d3a7b713fab0a8eb (diff) | |
| download | pardes-89fb37907f34c0a55b85da44ea8f016b3e41081d.tar.gz pardes-89fb37907f34c0a55b85da44ea8f016b3e41081d.zip | |
Messages: a message's cause longer than its word's room (Said.src, 96 bytes) keeps the path's END, `…` first, so the file's name is whole: causeWord set the path and Buf.set kept its first 96 bytes, so a file whose path is 97 bytes or more was named by a cut-off word on the notice row (S2 08b at 16 px: `…/core/Query.zi the build …`, the `g` lost, a Look on it a file that is not there); the notice row's "its words name it already" check reads a cut cause by what it kept, so `saved PATH` still leaves it out; no layout change (src stays 96 bytes); TEST FIRST: Messages "a cause longer than its word's room keeps the path's end ..." (fails on the base at Messages.zig:1694, the cause not starting with `…`); a user hits it with any message about a pane whose path is 97 bytes or longer
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/Messages.zig | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index 72d5193d..90194e30 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -297,8 +297,16 @@ pub fn say(p: *Pardes, kind: Kind, id: usize, text: []const u8) *Said { /// A pane as a message names its cause: a file's path (a kind's too), else /// `@pN` and the command it runs. fn causeWord(pane: *const Pane, out: *Buf(96)) void { - if (pane.file) |f| return out.set(f.path); - if (pane.addon) |k| if (k.path.len > 0) return out.set(k.path); + const path = if (pane.file) |f| f.path else if (pane.addon) |k| k.path else ""; + if (path.len > 0) { + if (path.len <= out.bytes.len) return out.set(path); + // Longer than the room: its end, `…` first, so its name is whole + // (UX D2: a path is cut from the left). + var from = path.len - (out.bytes.len - "\u{2026}".len); + while (from < path.len and path[from] & 0xC0 == 0x80) from += 1; + _ = out.print("\u{2026}{s}", .{path[from..]}); + return; + } const line = pane.command orelse { _ = out.print(config.pane_addr ++ "{d}", .{pane.serial}); return; @@ -729,9 +737,12 @@ pub fn noticeRow(p: *Pardes, width: usize, out: *[notice_row_cap]u8) Row { w.writeAll(line) catch {}; } else if (lead) |s| { w.print("{s} ", .{s.kind.glyph()}) catch {}; - // Its cause first, unless its words name it already. + // Its cause first, unless its words name it already (a cut one by + // what it kept). const words = s.words(); - if (s.src.len > 0 and std.mem.indexOf(u8, words, s.src.slice()) == null) w.print("{s} ", .{s.src.slice()}) catch {}; + const cause = s.src.slice(); + const named = if (std.mem.startsWith(u8, cause, "\u{2026}")) cause["\u{2026}".len..] else cause; + if (cause.len > 0 and std.mem.indexOf(u8, words, named) == null) w.print("{s} ", .{cause}) catch {}; w.writeAll(words) catch {}; if (s.n > 1) w.print(" \u{d7}{d}", .{s.n}) catch {}; for (s.places[0..s.places_len], 0..) |*place, i| w.print("{s} {s}:{d}:{d}", .{ if (i > 0) " \u{b7}" else "", place.path.slice(), place.line, place.col }) catch {}; @@ -1680,3 +1691,27 @@ test "the notice row's left is cut with `…` two blanks before its right block row = noticeRow(p, 200, &buf); try std.testing.expect(std.mem.indexOf(u8, row.text, "…") == null); } + +test "a cause longer than its word's room keeps the path's end, `…` first, so the file's name is whole (S2 08b at 16 px: `…/core/Query.zi`, its last letter lost)" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 200, .rows = 24 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + const long = "/tmp/claude-1000/wS2g16/proj/a/rather/long/way/down/to/the/sources/of/this/project/core/Query.zig"; + p.gpa.free(pane.file.?.path); + pane.file.?.path = try p.gpa.dupe(u8, long); + p.messages.live_len = 0; + const s = say(p, .notice, id, "the build finished"); + try std.testing.expect(std.mem.startsWith(u8, s.src.slice(), "\u{2026}")); + try std.testing.expect(std.mem.endsWith(u8, long, s.src.slice()["\u{2026}".len..])); + // The notice row names the file whole, its words after it. + var buf: [notice_row_cap]u8 = undefined; + var row = noticeRow(p, 190, &buf); + try std.testing.expect(std.mem.endsWith(u8, row.text[0..row.left], "/core/Query.zig the build finished")); + // Words that name the path already leave the cause out, cut or not + // (S2 08a: `saved PATH`). + p.messages.live_len = 0; + _ = say(p, .notice, id, "saved " ++ long); + row = noticeRow(p, 190, &buf); + try std.testing.expectEqualStrings("\u{b7} saved " ++ long, row.text[0..row.left]); +} |
