From 414668c4cd90a156795d9d6acb09c67e27a4a8b3 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 12 Feb 2026 14:00:22 +0100 Subject: [PATCH] refactor: add Editor.get_vcs_blame --- src/buffer/Buffer.zig | 2 +- src/tui/editor.zig | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/buffer/Buffer.zig b/src/buffer/Buffer.zig index 679a150..110e952 100644 --- a/src/buffer/Buffer.zig +++ b/src/buffer/Buffer.zig @@ -2,7 +2,7 @@ const std = @import("std"); const builtin = @import("builtin"); const cbor = @import("cbor"); const TypedInt = @import("TypedInt"); -const VcsBlame = @import("VcsBlame"); +pub const VcsBlame = @import("VcsBlame"); const file_type_config = @import("file_type_config"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 27e44e8..287bcd1 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1538,13 +1538,16 @@ pub const Editor = struct { return if (head_line < 0) null else @intCast(head_line); } + pub fn get_vcs_blame(self: *const Self, row: usize) ?*const Buffer.VcsBlame.Commit { + const buffer = self.buffer orelse return null; + const blame_row = self.get_delta_lines_until_row(row) orelse return null; + return buffer.get_vcs_blame(blame_row) orelse return null; + } + fn render_blame(self: *Self, theme: *const Widget.Theme, hl_row: ?usize, cell_map: CellMap) !void { const cursor = self.get_primary().cursor; const pos = self.screen_cursor(&cursor) orelse return; - const buffer = self.buffer orelse return; - - const blame_row = self.get_delta_lines_until_row(cursor.row) orelse return; - const commit = buffer.get_vcs_blame(blame_row) orelse return; + const commit = self.get_vcs_blame(cursor.row) orelse return; const screen_width = self.view.cols; var space_begin = screen_width;