feat: add synchronous diff and edit support to diff module

This commit is contained in:
CJ van den Berg 2024-10-29 20:43:33 +01:00
parent 7dd0fbf7b4
commit d412f92cc4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 201 additions and 92 deletions

View file

@ -31,7 +31,7 @@ relative: bool,
highlight: bool,
width: usize = 4,
editor: *ed.Editor,
diff: diff,
diff: diff.AsyncDiffer,
diff_symbols: std.ArrayList(Symbol),
const Self = @This();
@ -310,11 +310,11 @@ fn diff_update(self: *Self) !void {
return self.diff.diff(diff_result, new, old, eol_mode);
}
fn diff_result(from: tp.pid_ref, edits: []diff.Edit) void {
fn diff_result(from: tp.pid_ref, edits: []diff.Diff) void {
diff_result_send(from, edits) catch |e| @import("log").err(@typeName(Self), "diff", e);
}
fn diff_result_send(from: tp.pid_ref, edits: []diff.Edit) !void {
fn diff_result_send(from: tp.pid_ref, edits: []diff.Diff) !void {
var buf: [tp.max_message_size]u8 = undefined;
var stream = std.io.fixedBufferStream(&buf);
const writer = stream.writer();