summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-22 00:22:40 -0300
committerGabriel Schneider <[email protected]>2026-11-22 00:24:47 -0300
commit2015baa4ccd26a74b51e7b7cda0eb3533a325142 (patch)
tree98ebfdce836b02a466d11b100d1674d1cf57e513 /core/File.zig
parent98ff1e611e2fd4cd7f1f3db855a6d52f53ab4b71 (diff)
downloadpardes-2015baa4ccd26a74b51e7b7cda0eb3533a325142.tar.gz
pardes-2015baa4ccd26a74b51e7b7cda0eb3533a325142.zip
layers: what round 5's picture got wrong against the design's words: a description row keeps its author and age in a pane narrower than it, its title what gives way (`jj.fitted`: the title cut to the room the row has, `File.bodyWidth`, with a `…` where it is cut, the same text the geometry lays out and `inkGhost` colours, whatever the horizontal scroll); at one place a change's ghost rows come before its own description (the description ranked right after its last ghost row there; descriptions of blocks closing just above still first, newest first: a hunk that changed a line and took the next away had put its description between them); a change the revset does not pin, between two it does, no longer shifts the older pins' ghost rows: jj's one log run now asks `((R) | (roots(R)::REV)) & files(F)` and marks each change `p` or `c` (`self.contained_in(R)` in the template, `logTemplate`), the unpinned ones' hunks kept only to carry places (`Hunk.carrier`, `Hunk.step`, `carried` walking the steps); and lines typed before jj's snapshot or while jj ran no longer shift them: a place jj gives is carried into the pane's text by the same alignment that lines the lanes up (`Moved`, from `provenance`: the lines both ends agree on), a ghost row whose place lies inside lines rewritten since is not drawn; tests at the pane's surface: a long title in a 50-column pane cut before ` t now`, the id in its lane's colour, author and age grey, in a terminal and a window; `b();` changed and `c();` taken by one hunk then its description; `old | last` with `mid` unpinned between them puts `c();` before `d();`; a line typed between the word and the worker's answer moves the six places one down, the client equal; core-test 908/1068 (160 skipped), shell-test 1110/1113 (3 skipped)
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig22
1 files changed, 18 insertions, 4 deletions
diff --git a/core/File.zig b/core/File.zig
index a94353d5..347f4809 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -19,6 +19,7 @@ const locations = @import("locations.zig");
const Colors = @import("colors.zig");
const Tables = @import("Tables.zig");
const Stream = @import("Stream.zig");
+const jj = @import("jj.zig");
const Pane = panes.Pane;
const Output = panes.Output;
const Mini = panes.mini;
@@ -399,7 +400,7 @@ pub fn renderedLineDisplayCol(tab: u16, pane: *const Pane, row: i32, line_text:
return prefix +| rawDisplayCol(tab, line_text[prefix..], byte_col - prefix);
}
-fn fitEnd(tab: u16, text: []const u8, start: usize, width: usize) usize {
+pub fn fitEnd(tab: u16, text: []const u8, start: usize, width: usize) usize {
var end = start;
var used: usize = 0;
while (used < width and end < text.len) {
@@ -757,7 +758,7 @@ fn edit(p: *Pardes, f: *State, off: usize, len: usize, bytes_in: []const u8, who
};
reportEdit(p, f, off, len, bytes);
// A pinned change's per-line values ride with the lines (jj.zig).
- if (p.changes.answers.items.len > 0) @import("jj.zig").edited(p, f, off, len, bytes);
+ if (p.changes.answers.items.len > 0) jj.edited(p, f, off, len, bytes);
if (f.mini) |*mini| mini.deinit(p.gpa);
f.mini = null;
if (f.line_starts.len > 0) shiftIndex(p.gpa, f, off, len, bytes);
@@ -1659,7 +1660,7 @@ fn paintAhead(p: *Pardes, pane: *Pane, f: *State) void {
/// The path a text's language is known by: a file at a revision's
/// (jj.zig) without its `@rev`.
pub fn langPath(f: *const State) []const u8 {
- return if (@import("jj.zig").of(f)) |r| r.path else f.path;
+ return if (jj.of(f)) |r| r.path else f.path;
}
pub fn supportsContext(pane: *const Pane) bool {
@@ -1686,6 +1687,12 @@ fn prepareContextRows(pane: *Pane, file: *State) void {
pub fn wrapWidth(pane: *const Pane, wrap: bool) usize {
if (!wrap or pane.rows > pane.wrap_line.len) return 0;
+ return bodyWidth(pane);
+}
+
+/// The cells a body row has for text after the gutter (and a cell for a
+/// wrapped line's marker).
+pub fn bodyWidth(pane: *const Pane) usize {
return @max(1, @as(usize, pane.cols -| gutterWidth(pane)) -| 1);
}
@@ -1813,7 +1820,14 @@ fn fillBody(comptime ghosted: bool, tab: u16, dst: ?[]u8, pane: *Pane, f: *State
if (ghosted and !context and body_at == 0 and ghost < pane.ghosts.len and pane.ghosts[ghost].at == body_line) {
const g = pane.ghosts[ghost];
const said = pane.ghost_text[g.text..][0..g.len];
- const shown = if (width > 0) said[0..fitEnd(tab, said, 0, width)] else said[modal.graphemeStart(said, @min(@as(usize, @intCast(@max(0, pane.hscroll))), said.len))..];
+ var fit: [jj.row_max]u8 = undefined;
+ // A description is one compact row whatever the scroll.
+ const shown = if (g.kind == .description)
+ jj.fitted(tab, said, bodyWidth(pane), &fit)
+ else if (width > 0)
+ said[0..fitEnd(tab, said, 0, width)]
+ else
+ said[modal.graphemeStart(said, @min(@as(usize, @intCast(@max(0, pane.hscroll))), said.len))..];
if (record_wrap) {
pane.wrap_line[i] = @intCast(body_line);
pane.wrap_col[i] = -1 - @as(i32, @intCast(ghost));