refactor: add Editor.get_vcs_blame

This commit is contained in:
CJ van den Berg 2026-02-12 14:00:22 +01:00
parent ac12252ce1
commit 414668c4cd
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 8 additions and 5 deletions

View file

@ -2,7 +2,7 @@ const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const cbor = @import("cbor"); const cbor = @import("cbor");
const TypedInt = @import("TypedInt"); const TypedInt = @import("TypedInt");
const VcsBlame = @import("VcsBlame"); pub const VcsBlame = @import("VcsBlame");
const file_type_config = @import("file_type_config"); const file_type_config = @import("file_type_config");
const Allocator = std.mem.Allocator; const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList; const ArrayList = std.ArrayList;

View file

@ -1538,13 +1538,16 @@ pub const Editor = struct {
return if (head_line < 0) null else @intCast(head_line); 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 { fn render_blame(self: *Self, theme: *const Widget.Theme, hl_row: ?usize, cell_map: CellMap) !void {
const cursor = self.get_primary().cursor; const cursor = self.get_primary().cursor;
const pos = self.screen_cursor(&cursor) orelse return; const pos = self.screen_cursor(&cursor) orelse return;
const buffer = self.buffer orelse return; const commit = self.get_vcs_blame(cursor.row) 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 screen_width = self.view.cols; const screen_width = self.view.cols;
var space_begin = screen_width; var space_begin = screen_width;