From b77eac2511cb247ebae07494bbb13b2e6a1139ab Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 24 Nov 2026 20:13:20 -0300 Subject: Pick: a picker unrolls in the tag of the pane its Enter lands in (walk UI, pick-ui SPEC.md §3.5, §5.1-§5.3, item 1 of line D): core/Pick.zig, a picker the session's (Pardes.picks, a ring of max_lists 8, each named by a serial from the panes' counter so the disk engine's target names it as it names a pane, Stream.receive giving it its batches through Query.take, now taking either), live in a view's tag as TagState kind pick (TagState.pick its serial, host its landing pane: the asking pane when it reads, else its reader, else a pane made for it where its reader would go, an empty +Preview until the preview fills it, taken away by Esc); its sources Query.zig's producers re-presented: Find's listing from the disk engine's worker and Recent, Panes, Symbols (Query.gather, the name gathering startSource did, now shared), the jump list (Output.jumpsText, what +Jumps lists) and a list's rows handed over (a language server's answer, titled by its word), all scored by Names a frame's count at a time; Grep's lines from the worker after its pause, All the places each open text finds (as Query's All); the head ` ␣ f Find pick 3/6 ⋯` (key cells from the source's leader keys, the word, the field, cursor/total, ⋯ while scoring or searching) and a second row of the other sources' words under spines continued from the key cells (TagState.Head.cells counts the second row's spines, which Band.findSpines hangs the band from); the band's rows eleven around the cursor, made in the frame's arena for the rows shown only (O(rows shown): a Find of 50k paths makes 11 rows a frame), a place prefix in the name's tint, a path's directory dimmed, matches in the match tint; the preview is the landing pane's body: the current row's file at its line (a Grep's matches lit as its places), taken from an open pane's text or read, on the frame after the cursor stood (never on the key that moved it: Pick.busy asks the frame), a reading pane's own text set aside meanwhile (Pick.aside) and put back when it rolls up, a twinned text never previewed in; TagState.toRest rolls a live picker up first, whoever puts the tag to rest; A's API: TagState.Kind pick and its pick field, Band.takes/of's pick arm, Band.Row mark/pre/faint (drawn in draw.zig joinBand), Band.place holding a step to the band's width, TagState.point on a picker's row; TEST FIRST: Pick.zig "a picker from a held pane unrolls in a reader made for it ..." and "a picker from a reading pane unrolls in that pane, its own text set aside while it previews and back on Esc"; core-test 1014/1180 (166 skipped), 0 failed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- core/Query.zig | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'core/Query.zig') diff --git a/core/Query.zig b/core/Query.zig index feebb6cd..4fbd07e0 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -713,7 +713,6 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz q.found.clearRetainingCapacity(); q.found_bytes.clearRetainingCapacity(); const dir = std.Io.Dir.path.dirname(rp.file.?.path) orelse "/"; - const gpa = p.gpa; switch (source) { // The files under the directory, listed once on the disk engine's // worker (rg --files, else the walk); each keystroke scores them. @@ -721,6 +720,19 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz Stream.query(p, rp.serial, .files, "", dir, .now) catch |err| return p.reportError(.at(id), "search", err); if (p.fs.serving) Stream.step(p); }, + .recent, .panes, .symbols => gather(p, &q.names, source, dir, rp, owner_id), + else => {}, + } +} + +/// The names a Recent, Panes or Symbols query scores, into `names`: the +/// files opened lately, the panes but `self` (then the ones this session +/// closed), the declarations of pane `owner_id`'s text (asked of the +/// worker when it has none yet: declsArrived gathers them). Rows relative +/// to `dir`. A query pane's, and a picker's (Pick.zig). +pub fn gather(p: *Pardes, names: *Names, source: Source, dir: []const u8, self: ?*const Pane, owner_id: ?usize) void { + const gpa = p.gpa; + switch (source) { .recent => { var out: std.Io.Writer.Allocating = .init(gpa); defer out.deinit(); @@ -729,19 +741,19 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz if (ln.len == 0) continue; const rel = relative(ln, dir); const path_end = std.mem.indexOfAny(u8, rel, ": ") orelse rel.len; - q.names.add(gpa, rel, 0, path_end, Names.baseOf(rel[0..path_end]), 0) catch break; + names.add(gpa, rel, 0, path_end, Names.baseOf(rel[0..path_end]), 0) catch break; } }, .panes => { for (p.panes) |slot| { const other = slot orelse continue; - if (other == rp or other.query != null) continue; + if (other == self or other.query != null) continue; var buf: [4096 + 32]u8 = undefined; const what: []const u8 = if (other.file) |f| f.path else if (other.command) |c| c else other.cwdSlice(); const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}", .{ other.serial, relative(what, dir) }) catch continue; const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1; const ln = row[0 .. std.mem.indexOfAny(u8, row, "\r\n") orelse row.len]; - q.names.add(gpa, ln, key_at, ln.len -| key_at, Names.baseOf(ln[@min(key_at, ln.len)..]), other.serial) catch break; + names.add(gpa, ln, key_at, ln.len -| key_at, Names.baseOf(ln[@min(key_at, ln.len)..]), other.serial) catch break; } // Then the panes this session closed, the latest first, each // `(closed)` and dimmer (makeNameRows): Enter brings one back @@ -752,7 +764,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz const row = std.fmt.bufPrint(&buf, config.pane_addr ++ "{d} {s}" ++ closed_word, .{ c.serial, relative(c.name, dir) }) catch continue; const key_at = std.mem.indexOfScalar(u8, row, ' ').? + 1; const key_len = row.len - closed_word.len - key_at; - q.names.add(gpa, row, key_at, key_len, Names.baseOf(row[key_at..][0..key_len]), c.serial) catch break; + names.add(gpa, row, key_at, key_len, Names.baseOf(row[key_at..][0..key_len]), c.serial) catch break; } }, .symbols => { @@ -769,7 +781,7 @@ fn startSource(p: *Pardes, id: usize, q: *Query, source: Source, owner_id: ?usiz const first = std.mem.trim(u8, header[0 .. std.mem.indexOfScalar(u8, header, '\n') orelse header.len], " \t\r"); var buf: [256 + 16]u8 = undefined; const row = std.fmt.bufPrint(&buf, "{d: >6} {s}", .{ d.start_line + 1, first[0..@min(first.len, 240)] }) catch continue; - q.names.add(gpa, row, 8, row.len - 8, 0, @intCast(d.start_line + 1)) catch break; + names.add(gpa, row, 8, row.len - 8, 0, @intCast(d.start_line + 1)) catch break; } }, else => {}, @@ -1253,10 +1265,11 @@ fn countGrepCurrent(q: *Query) void { if (c < q.items.items.len and q.items.items[c].kind == .hit) q.k = q.items.items[c].hit + 1; } -/// The disk engine's rows for query pane `q` (Stream.receive): a Grep's -/// lines (`path:line:col-end code`, relative to the pane's directory) kept -/// as found, a listing's names added to what Find scores. -pub fn take(p: *Pardes, q: *Query, kind: Stream.Kind, rows: []const u8) void { +/// The disk engine's rows for query pane `q` (Stream.receive), or for a +/// picker (Pick.zig: the same fields): a Grep's lines (`path:line:col-end +/// code`, relative to the pane's directory) kept as found, a listing's +/// names added to what Find scores. +pub fn take(p: *Pardes, q: anytype, kind: Stream.Kind, rows: []const u8) void { var lines = std.mem.splitScalar(u8, rows, '\n'); while (lines.next()) |ln| { if (ln.len == 0) continue; -- cgit v1.3