refactor: add diffz support and use it for gutter diffs
This commit is contained in:
parent
1e02d978de
commit
cf28e27a81
7 changed files with 464 additions and 268 deletions
|
|
@ -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| {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue