Compare commits
2 commits
640904addd
...
6603e60951
| Author | SHA1 | Date | |
|---|---|---|---|
| 6603e60951 | |||
|
|
9ab1b78a53 |
1 changed files with 27 additions and 1 deletions
|
|
@ -1475,11 +1475,37 @@ pub const Editor = struct {
|
|||
_ = self.plane.putc(&cell) catch {};
|
||||
}
|
||||
|
||||
/// Get delta line from HEAD version with diffs
|
||||
inline fn get_delta_lines_until_row(self: *const Self, row_: usize) ?usize {
|
||||
const row: isize = @intCast(row_);
|
||||
var delta_lines: isize = 0;
|
||||
|
||||
for (self.changes.items) |change| {
|
||||
if (change.line > row)
|
||||
break;
|
||||
|
||||
if (change.kind == .insert)
|
||||
if (row >= change.line and row < change.line + change.lines)
|
||||
return null;
|
||||
|
||||
switch (change.kind) {
|
||||
.insert => delta_lines -= @intCast(change.lines),
|
||||
.delete => delta_lines += @intCast(change.lines),
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
const head_line = delta_lines + row;
|
||||
return if (head_line < 0) null else @intCast(head_line);
|
||||
}
|
||||
|
||||
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 commit = buffer.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;
|
||||
|
||||
var buf: std.Io.Writer.Allocating = .init(self.allocator);
|
||||
defer buf.deinit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue