diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-24 11:57:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-24 12:21:18 -0300 |
| commit | 8ac6db5662dd2db0f082e1651835f1db36e235f8 (patch) | |
| tree | ae8a8e928ca774b4347e4d19a8bf083c397e909b /src/pardes.zig | |
| parent | 51903dd947f90381d1a908c488a019289a1c8413 (diff) | |
| download | pardes-8ac6db5662dd2db0f082e1651835f1db36e235f8.tar.gz pardes-8ac6db5662dd2db0f082e1651835f1db36e235f8.zip | |
Search converge 4/6: the disk engine, Grep and Find's listing on a worker (rg when there, else a sorted walk), generation-numbered batches, a debounce, a 2000-line cap and More, and the declarations parse off the loop
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 1b4e9920..3ccfee5f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -25,6 +25,7 @@ pub const Messages = @import("Messages.zig"); pub const Registers = @import("Registers.zig"); pub const Macro = @import("Macro.zig"); pub const Pipe = @import("Pipe.zig"); +pub const Stream = @import("Stream.zig"); pub const colors = @import("colors.zig"); pub const Theme = colors.Theme; pub const themes = colors.themes; @@ -488,6 +489,7 @@ test { _ = @import("Places.zig"); _ = @import("Query.zig"); _ = @import("Names.zig"); + _ = @import("Stream.zig"); } pub const Builtin = builtins.registry.Builtin(); @@ -3669,6 +3671,8 @@ pub const Event = union(enum) { failure: ?selection_pipe.Failure = null, }, file_changed: struct { pane: u8, bytes: []const u8 }, + /// A disk search's batch (Stream.zig), borrowed for the step. + search: Stream.Batch, paste: []const u8, command: []const u8, /// Native shells may preserve sub-cell wheel distance in physical pixels. @@ -3725,6 +3729,9 @@ pub const Effect = union(enum) { /// Snapshot the matching request with pipeRequest(id), then run it away /// from the UI/event loop and answer with pipe_resp. pipe: struct { id: u32 }, + /// Start the disk search of this generation (Stream.start) on a worker + /// posting into the shell's inbox. + search: struct { gen: u32 }, /// Write what an Edit's `w` took (`Pipe.writes`), in order. edit_write, watch: struct { pane: u8, on: bool, mode: WatchMode = .reconcile }, @@ -4584,6 +4591,8 @@ pub const Pardes = struct { } = null, pipe: Pipe = .{}, + /// A query pane's Grep, and its Find's listing, on a worker (Stream.zig). + stream: Stream = .{}, fs: filesystem.Namespace = .{}, boot: Boot = .shell, @@ -4950,6 +4959,7 @@ pub const Pardes = struct { if (p.chord_arg) |a| gpa.free(a); for (p.spawn_dirs) |d| if (d) |dir| gpa.free(dir); p.pipe.deinit(gpa); + p.stream.deinit(gpa); p.locations_cache.deinit(p.tree_sitter_gpa); p.fs.deinit(gpa); p.shell_rows.reset(gpa); @@ -5547,7 +5557,7 @@ pub const Pardes = struct { pub fn postEvent(p: *Pardes, ev: Event) void { switch (ev) { .key => |k| std.debug.assert(k.text.len == 0), - .output, .paste, .lsp_resp, .pipe_resp, .file_changed, .command => unreachable, + .output, .paste, .lsp_resp, .pipe_resp, .search, .file_changed, .command => unreachable, else => {}, } if (p.in_len == p.in_q.len) return; @@ -5846,6 +5856,8 @@ pub const Pardes = struct { f(p.host.ctx, q.id) else p.update(.{ .pipe_resp = .{ .id = q.id, .success = false, .outputs = &.{} } }), + // No workers here (a test, a board): it runs on the loop. + .search => |q| if (v.search) |f| f(p.host.ctx, q.gen) else Stream.runHere(p, q.gen), .edit_write => { // Each write takes the bytes `w` took when it ran: the text // as it was before the Edit's changes. @@ -5995,7 +6007,8 @@ pub const Pardes = struct { pane.msg_announcement = false; }; switch (ev) { - .tick => {}, + // A batch of rows coming in is no gesture: a Look's hover stays. + .tick, .search => {}, .mouse => |m| if (!(m.button == .none and m.kind == .motion)) { p.raw_hover_intent = false; look.cancelLookHover(p); @@ -6026,6 +6039,7 @@ pub const Pardes = struct { p.clip_pending = null; }, .tick => { + Stream.step(p); Messages.advanceMessages(p); for (0..p.panes.len) |id| exec.flushReplEnter(p, id, false); }, @@ -6090,6 +6104,7 @@ pub const Pardes = struct { }, .lsp_resp => |r| p.lspResponse(r.id, r.rows), .pipe_resp => |r| Pipe.pipeResponse(p, r.id, r.success, r.outputs, r.failure), + .search => |b| Stream.receive(p, &b), .file_changed => |fc| _ = p.applyWatchedFileChanged(fc.pane, fc.bytes), .key => |key| { p.can_ask = true; @@ -7632,7 +7647,11 @@ pub const Pardes = struct { // Places still to find resume on the next frame. for (p.panes) |slot| if (slot) |pane| if (pane.places.busy(pane)) return next; if (panes.Query.busy(p)) return next; + // A typed Grep waiting out its pause. + const streaming = p.stream.wake(next); + if (streaming) |due| if (due <= next) return next; var frames: ?u64 = null; + if (streaming) |due| frames = @max(1, (due -| p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns); if (p.look_hover_wait) |waiting| { const delay = config.look_preview_delay_frames orelse return next; frames = @max(1, delay -| waiting.frames); |
