From b17ff3c29dc5b0eb03fe471be9b96098cbb631f8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:16:33 -0300 Subject: Pick: a list of places (a Grep's hits, All's, a list's: Refs, SPC e's errors, a server's symbols) shows each row's place in the dim ink and its text after it in one column, the widest place shown before it (UX E7 2b, D4/D5): THE CAUSE: Pick.rowAt wrote `path:line code` with one blank between them and the band drew its `pre` (the place) in the tag's name tint, so every row repeated `Jump.zig:76` as loud as the code (8.4:1 against the code's 8.8:1) and the code started at a ragged column (UX2/before: the old +Search grouped hits under a file line with the code in one column, `path:line:col` dim); THE FIX: Pick.steps, for those sources, gives each row whose place has text after it Band.Row.quiet over the place up to its blank (a column `:3:1` and the `:` of a compiler's `path:line:col: words` are the place's), which the band draws in the dim ink of its ground over the name tint, and pads the place to the widest one shown, the matched letters moved with the text; bounded by the rows shown (the band's window), nothing at rest or for any other picker; TEST FIRST: Pick.zig "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)" (fails on the base: Row.quiet 0..0); GOLDENS: fsearch's list and ctrln snaps (rows 18 and 19: `g.txt:2:1: MARK a`, `g.txt:6:1: MARK b` padded to `g.txt:10:1: MARK c`'s column) and lsp's symbols snap (rows 4 and 5: `a.zig:1:7-9 std`, `a.zig:3:4-9 helper` padded to `a.zig:7:8-11 main`'s), regenerated with process-test -- --update fsearch / lsp and read, no other row moved (these snaps keep no style rows for the band); core-test 1087/1258 (171 skipped), process-test 2 of 147 failed before the goldens (fsearch, lsp), 0 after Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Pick.zig | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'core/Pick.zig') diff --git a/core/Pick.zig b/core/Pick.zig index c5b639cd..8239be6a 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -715,6 +715,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; } @@ -2395,3 +2419,40 @@ 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]); +} -- cgit v1.3 From ae138cd257f862f226f3f9561b98b7c0518bfcf5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 25 Nov 2026 10:34:20 -0300 Subject: Pick: a code action Enter cannot apply shows so before Enter: a command's (no edit) and one whose edit reaches other files are dim rows with the meta `command` or `other files` at their right end (UX E5 12, D4/D5), where they looked like every other row and Enter on them said it after the fact (P3's apply refusals, UX E4 P3.2); THE FIX: rowAt's actions arm reads the action first and marks those two with Band.Row.dim and Band.Row.meta (P2's right-aligned dim meta, given way before the title), the rest as before; the edit's first line already sits ⌈rows/3⌉ down the body (the merge's look.focusPaneLine .third, D7/E3): the test asks it; TEST FIRST: Pick.zig "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)" (fails on the base at Pick.zig:2480: the command's row not dim), passes now with P3's code actions test; core-test 1088/1259 (171 skipped) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/Pick.zig | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'core/Pick.zig') diff --git a/core/Pick.zig b/core/Pick.zig index 8239be6a..1d0df89f 100644 --- a/core/Pick.zig +++ b/core/Pick.zig @@ -559,11 +559,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 } } }; @@ -2456,3 +2464,42 @@ test "a list of places (a Grep's, a list's) shows each row's `path:line` in the // One cell after the widest place. try std.testing.expectEqual(File.displayWidth(8, b_path) + ":1:4 ".len, 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); + // 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); +} -- cgit v1.3