diff options
Diffstat (limited to 'core/Stream.zig')
| -rw-r--r-- | core/Stream.zig | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/Stream.zig b/core/Stream.zig index f65d0683..1d061b52 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 }; @@ -73,6 +74,8 @@ pub const Batch = struct { /// A paint's answer (`paintAhead`): the colours of pane `serial`'s text /// at `revision` from byte `start`, one syntax.Syn a byte. painted: ?struct { serial: u32, revision: u32, start: usize } = null, + /// Or, with a `Changes` generation (jj.gen_bit), jj's annotate (jj's + /// log in `rows`, or its refusal and `end` failed). styles: []u8 = &.{}, pub const End = enum { done, failed }; @@ -138,7 +141,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,7 +257,6 @@ 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, - pub fn deinit(s: *Stream, gpa: std.mem.Allocator) void { s.cancelTask(); s.cancelParse(); @@ -584,6 +586,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 +640,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| { @@ -688,6 +692,7 @@ 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.painted != null) return receivePaint(p, b); + if (b.gen & jj.gen_bit != 0) return jj.receive(p, b); if (b.gen != s.gen or (s.state != .searching and s.state != .capped)) { s.dropped += 1; return; |
