diff options
Diffstat (limited to 'core/Stream.zig')
| -rw-r--r-- | core/Stream.zig | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/Stream.zig b/core/Stream.zig index f65d0683..80812840 100644 --- a/core/Stream.zig +++ b/core/Stream.zig @@ -25,6 +25,7 @@ const look = @import("look.zig"); const panes = @import("panes.zig"); const syntax = @import("syntax.zig"); const Pardes = pardes.Pardes; +const jj = @import("jj.zig"); pub const Kind = enum { grep, files }; pub const Engine = enum { rg, walk }; @@ -74,6 +75,10 @@ pub const Batch = struct { /// at `revision` from byte `start`, one syntax.Syn a byte. painted: ?struct { serial: u32, revision: u32, start: usize } = null, styles: []u8 = &.{}, + /// A `Changes` answer (jj.zig) for pane `jj`, by serial: jj's log in + /// `rows` and its annotate in `styles`, or its refusal in `rows` and + /// `end` failed. + jj: ?u32 = null, pub const End = enum { done, failed }; @@ -138,7 +143,7 @@ const TextTask = struct { /// A worker joined, the turn out for it as for any blocking call (it may /// be reading through a mount of this very session): canceled, or waited /// for once it has sent its last. -fn join(future: std.Io.Future(void), io: std.Io, how: enum { cancel, wait }) void { +pub fn join(future: std.Io.Future(void), io: std.Io, how: enum { cancel, wait }) void { pardes.turn.yield(); var f = future; if (how == .cancel) f.cancel(io) else f.await(io); @@ -254,8 +259,14 @@ rows_asked_at: u8 = 0, /// Rows asked for their colours while a 9P write was served: asked again /// on the next step (Query.produceAll). rows_later: bool = false, +/// The `Changes` asked of jj and its worker, the one asked while it ran, +/// and how many were asked (jj.zig: one at a time, the last one pinned). +changes: ?jj.Task = null, +changes_next: ?*jj.Ask = null, +changes_count: u32 = 0, pub fn deinit(s: *Stream, gpa: std.mem.Allocator) void { + jj.cancel(s); s.cancelTask(); s.cancelParse(); s.cancelPaint(); @@ -584,6 +595,7 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, p: *Pardes, gen: u32, ctx: ?*an }; return; } + if (gen & jj.gen_bit != 0) return jj.start(io, gpa, p, gen, ctx, sink); // A parse's generation: its own task. if (s.parse) |*t| if (gen == s.parse_gen and t.job.gen == gen and t.future == null) { t.job.out = gpa; @@ -637,6 +649,7 @@ pub fn runHere(p: *Pardes, gen: u32, comptime in_call: bool) void { }; return; } + if (gen & jj.gen_bit != 0) return jj.runHere(p, gen, in_call); const s = &p.stream; if (gen != s.gen or s.state != .searching) return; const job = makeJob(p.gpa, s) catch |err| { @@ -687,6 +700,7 @@ const Collect = struct { pub fn receive(p: *Pardes, b: *const Batch) void { const s = &p.stream; if (b.parsed) |parsed| return receiveParse(p, b, parsed.serial, parsed.revision); + if (b.jj) |serial| return jj.receive(p, b, serial); if (b.painted != null) return receivePaint(p, b); if (b.gen != s.gen or (s.state != .searching and s.state != .capped)) { s.dropped += 1; |
