diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 12:00:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 12:09:48 -0300 |
| commit | 8af71053adc306b81c39429d6d1758bb6c81d363 (patch) | |
| tree | 4f4dd30cfba4db91da523104025fe544d2fc1a6b /core/Pick.zig | |
| parent | 40f4750dc3fe870349c13649d22b4687896bbf7b (diff) | |
| parent | ae138cd257f862f226f3f9561b98b7c0518bfcf5 (diff) | |
| download | pardes-8af71053adc306b81c39429d6d1758bb6c81d363.tar.gz pardes-8af71053adc306b81c39429d6d1758bb6c81d363.zip | |
walk UI M7: the fix round's X1 (lrzulkwu 40f4750dc3fe: band rows in the dumps and the digest (the soak's `views[0].rects` class), a picker's band capped at 40 % of its host pane at open E5.1, the band under the head E5.2, the notice row cut with `…` E5.4, a blank each side of a step's rule E5.5, Help's chord and word with its group as right-aligned meta E5.6, a doc with no room on the notice row E5.10, full-height `│` in the window E5.9, the tag rule under a band over a terminal E5.11) merged with X2 (suvlqwul ae138cd257f8: the soak typist's q guard, a message's detail only on request E5.3/D13, the err role's fallback E5.7, ` · N lines` kept dim after a search's count (E7's reversal of E5.8), a list of places in one column with its places dim E7 2b, the landing line at 1.5:1 and its span at 1.9:1 E7 7b, code actions Enter cannot apply dim with meta `command`/`other files` E5.12), both on G4's lurxouvq, resolved by meaning: the only text conflict was test/snapshots/fsearch.golden; Messages.noticeRow (X1's left-text cut and doc line, its `*Pardes` signature) and X2's D13 (detailUnder, detailAt, act, rollUp) touch different functions and merged clean, as did Core.zig (X1's sync, X2's updateInner arms) and Pick.zig (X1's `cap` and bandRows, X2's rowAt actions arm and steps' place column); BY MEANING: X1's E3 rule gives the band's last list step the remaining width, so X2's place column (padded to the widest place shown, Pick.steps) is no longer cut at 52 cells and still lines up (a row with a place is cut from the right by Band.cutRow, its `pre` set, so the column never shifts), and the actions picker's one step is the band's width, so its meta `command`/`other files` stands at the band's right end (X2's reading 8 asked for exactly that); TESTS (the merge's checks): Pick "a list of places ..." also asks the band's drawn rows (Band.of, band.line): the last step ends at the band's edge and the two rows' code in one column; Pick "code actions: a row that cannot be applied ..." also asks the band's first row to end ` command` at the band's width; GOLDEN: fsearch regenerated and every changed row read: against X1 only X2's rows (`g.txt:2:1: MARK a` and `6:1: MARK b` padded to `10:1: MARK c`'s column in list and ctrln, row 16's ` · N lines` cells in the dim ink); against X2 only X1's (the band from the row under the head, the reader borrowing a row so its body shows line 9 / 11, the stray `│` under the `/` prompt gone); no other golden moved; core-test 1095/1266 (171 skipped; X1 1090/1261 + X2 1088/1259 over the base's 1083/1254), the two extended tests filtered 11/11 each; process-test 1 of 147 failed before the update (fsearch, the conflicted golden) and fsearch 0 of 1 after it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Pick.zig')
| -rw-r--r-- | core/Pick.zig | 127 |
1 files changed, 126 insertions, 1 deletions
diff --git a/core/Pick.zig b/core/Pick.zig index fe7454b3..10c80dfc 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -564,11 +564,19 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) !Row { // changes, which the body is moved to while it is previewed. .actions => { row.key = @intFromBool(cand.ref < 9); + const act = action(pk, cand.ref) orelse return row; + // One Enter cannot apply (apply's refusals): dim, saying why + // (UX E5 12). + if (act.records.len == 0 or std.mem.eql(u8, act.records, "@elsewhere\n")) { + row.dim = true; + row.meta = if (act.records.len == 0) "command" else "other files"; + return row; + } const owner = p.panes[p.paneBySerial(pk.landing) orelse return row].?; // With the `Changes` layer's lines shown the body stays where it is. const f = if (owner.file) |*file| file else return row; if (f.layer.lines.len > 0 or f.revision != pk.revision) return row; - const edits = pardes.lsp.Ask.parseLspEdits(arena, (action(pk, cand.ref) orelse return row).records, null) orelse return row; + const edits = pardes.lsp.Ask.parseLspEdits(arena, act.records, null) orelse return row; if (edits[0].start > f.content.len) return row; const line = @import("Places.zig").lineOf(try File.lineIndex(p.gpa, f), edits[0].start); row.target = .{ .place = .{ .path = f.path, .at = .{ .line = line + 1 } } }; @@ -717,6 +725,30 @@ pub fn steps(p: *Pardes, arena: std.mem.Allocator) ![]Band.Step { const r = try rowAt(p, pk, arena, i); row.* = .{ .text = r.text, .key = r.key, .on = i == s.rows.at, .mark = marked(pk, idOf(pk, i)) != null, .dim = r.dim, .pre = r.pre, .faint = r.faint, .marks = r.marks, .index = @intCast(i), .meta = r.meta }; } + // A place's text (a Grep's line, a list's): its `path:line` in the dim + // ink and the text after it in one column, the widest place shown + // before it (UX E7 2b: the old +Search's column). Bounded by the rows + // shown. + if (pk.source == .grep or pk.source == .all or pk.source == .list) { + var widest: usize = 0; + for (rows) |row| if (row.pre > 0 and row.pre < row.text.len) { + widest = @max(widest, File.displayWidth(p.settings.tab, row.text[0 .. std.mem.indexOfScalarPos(u8, row.text, row.pre, ' ') orelse row.text.len])); + }; + for (rows) |*row| if (row.pre > 0 and row.pre < row.text.len) { + // The place up to its blank: a column (`:3:1`) and the `:` a + // compiler's `path:line:col: words` puts after it are its. + const end = std.mem.indexOfScalarPos(u8, row.text, row.pre, ' ') orelse row.text.len; + row.quiet = .{ 0, @intCast(end) }; + const pad = widest - File.displayWidth(p.settings.tab, row.text[0..end]); + if (pad == 0) continue; + const blanks = try arena.alloc(u8, pad); + @memset(blanks, ' '); + row.text = try std.mem.concat(arena, u8, &.{ row.text[0..end], blanks, row.text[end..] }); + const marks = try arena.alloc(u16, row.marks.len); + for (marks, row.marks) |*m, at| m.* = if (at >= end) at + @as(u16, @intCast(pad)) else at; + row.marks = marks; + }; + } out[0] = .{ .rows = rows }; return out; } @@ -2429,3 +2461,96 @@ test "a picker's preview is legible as one (UX D7): its landing line on the hit p.update(.{ .key = .{ .cp = pardes.Key.escape } }); try std.testing.expect(!pardes.Messages.noticeRow(p, 120, &buf).quiet_left); } + +test "a list of places (a Grep's, a list's) shows each row's `path:line` in the dim ink and its text after it in one column, the widest place shown before it (UX E7 2b)" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const a_path = try testFile(p, &tmp, "a.zig", "one\ntwo\nconst x = 1;\n"); + defer p.gpa.free(a_path); + const b_path = try testFile(p, &tmp, "a_longer_name.zig", "fn y() void {}\n"); + defer p.gpa.free(b_path); + _ = try p.setTestFile("held\n"); + const asker = p.view().active; + Trail.keep(p.panes[asker].?); + const rows = try std.fmt.allocPrint(std.testing.allocator, "{s}:3:1 const x = 1;\n{s}:1:4 fn y() void {{}}\n", .{ a_path, b_path }); + defer std.testing.allocator.free(rows); + open(p, asker, .list, "Refs", "", rows); + p.update(.tick); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const got = (try steps(p, frame.allocator()))[0].rows; + try std.testing.expectEqual(@as(usize, 2), got.len); + const code = [2][]const u8{ "const x = 1;", "fn y() void {}" }; + var col: [2]usize = undefined; + for (got, code, &col) |row, text, *c| { + const at = std.mem.indexOf(u8, row.text, text).?; + c.* = File.displayWidth(8, row.text[0..at]); + // The place dim up to its blank (`path:3:1`); the text after it not. + try std.testing.expect(row.pre > 0); + try std.testing.expectEqual(@as(u16, 0), row.quiet[0]); + try std.testing.expectEqual(':', row.text[row.quiet[1] - 2]); + try std.testing.expectEqual(' ', row.text[row.quiet[1]]); + } + try std.testing.expectEqual(col[0], col[1]); + // One cell after the widest place. + try std.testing.expectEqual(File.displayWidth(8, b_path) + ":1:4 ".len, col[1]); + // As the band draws them, its last step the band's width (UX E3): the + // text still in one column. + const host = TagState.hostOf(p).?; + const band = (try Band.of(p, frame.allocator(), p.panes[host].?, host)).?; + const last = band.steps[band.nsteps - 1]; + try std.testing.expectEqual(band.columns, last.x + last.width); + for (code, &col, 0..) |text, *c, y| { + const ln = try band.line(frame.allocator(), p.settings.tab, @intCast(y)); + c.* = File.displayWidth(p.settings.tab, ln.text[0..std.mem.indexOf(u8, ln.text, text).?]); + } + try std.testing.expectEqual(col[0], col[1]); +} + +test "code actions: a row that cannot be applied (a command's, an edit reaching other files) is dim, its meta `command` or `other files`; the edit under the cursor a third of the way down the body (UX E5 12, D7)" { + const Key_ = pardes.Key; + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }); + defer p.deinit(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + p.settings.jumps = .walk; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(std.testing.allocator); + for (1..81) |i| try text.print(std.testing.allocator, "line {d}\n", .{i}); + const pane = try p.setTestFile(text.items); + const id = p.view().active; + // Line 50 starts after lines 1-49. + var at: usize = 0; + for (1..50) |i| at += std.fmt.count("line {d}\n", .{i}); + const rows = try std.fmt.allocPrint(frame.allocator(), "x:1:1 extract\nx:1:1 move to a new file\n@elsewhere\nx:1:1 rename\n@put {d} {d} LINE\n", .{ at, at + 4 }); + open(p, id, .actions, "", "", rows); + live(p).?.revision = pane.file.?.revision; + const got = (try steps(p, frame.allocator()))[0].rows; + try std.testing.expectEqual(@as(usize, 3), got.len); + try std.testing.expect(got[0].dim); + try std.testing.expectEqualStrings("command", got[0].meta); + try std.testing.expect(got[1].dim); + try std.testing.expectEqualStrings("other files", got[1].meta); + try std.testing.expect(!got[2].dim); + try std.testing.expectEqualStrings("", got[2].meta); + // As the band draws it, its step the band's width (UX E3): the meta + // at the band's right end. + const band = (try Band.of(p, frame.allocator(), pane, TagState.hostOf(p).?)).?; + const ln = try band.line(frame.allocator(), p.settings.tab, 0); + try std.testing.expect(std.mem.endsWith(u8, ln.text, " command")); + try std.testing.expectEqual(@as(usize, band.columns), File.displayWidth(p.settings.tab, ln.text)); + // The rename's: its line (50) a third of the way down the body. + p.update(.{ .key = .{ .cp = Key_.down } }); + p.update(.{ .key = .{ .cp = Key_.down } }); + settle(p); + p.sync(); + var row_at: ?u16 = null; + for (0..pane.rows) |row| if (pane.wrapAt(p.settings.tab, @intCast(row)).line == 49) { + row_at = @intCast(row); + break; + }; + try std.testing.expectEqual(@as(?u16, @intCast((pane.rows + 2) / 3)), row_at); +} |
