refactor: add diffz support and use it for gutter diffs

This commit is contained in:
CJ van den Berg 2026-01-13 16:14:57 +01:00
parent 1e02d978de
commit cf28e27a81
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
7 changed files with 464 additions and 268 deletions

View file

@ -5156,7 +5156,7 @@ pub const Editor = struct {
const frame = tracy.initZone(@src(), .{ .name = "editor diff syntax" });
defer frame.deinit();
const diff = @import("diff");
const edits = try diff.diff(self.allocator, content, old_content.written());
const edits = try diff.dizzy.diff(self.allocator, content, old_content.written());
defer self.allocator.free(edits);
for (edits) |edit|
syntax_process_edit(syn, edit);
@ -6087,7 +6087,7 @@ pub const Editor = struct {
var last_end_row: usize = 0;
var last_end_col_pos: usize = 0;
const diffs = try @import("diff").diff(self.allocator, new_content, content);
const diffs = try @import("diff").dizzy.diff(self.allocator, new_content, content);
defer self.allocator.free(diffs);
var first = true;
for (diffs) |diff| {

View file

@ -35,7 +35,7 @@ symbols: bool,
width: usize = 4,
editor: *ed.Editor,
editor_widget: ?*const Widget = null,
diff_: diff.AsyncDiffer,
diff_: diff.diffz.AsyncDiffer,
diff_symbols: std.ArrayList(Symbol),
const Self = @This();
@ -55,7 +55,7 @@ pub fn create(allocator: Allocator, parent: Widget, event_source: Widget, editor
.highlight = tui.config().highlight_current_line_gutter,
.symbols = tui.config().gutter_symbols,
.editor = editor,
.diff_ = try diff.create(),
.diff_ = try diff.diffz.create(),
.diff_symbols = .empty,
};
try tui.message_filters().add(MessageFilter.bind(self, filter_receive));