refactor: notify editors on vcs_content updates

This commit is contained in:
CJ van den Berg 2025-12-17 22:09:14 +01:00
parent 3fb4bd6510
commit 4d1eaa767b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 6 additions and 0 deletions

View file

@ -1857,6 +1857,10 @@ pub const Editor = struct {
tp.self_pid().send(.{ "cmd", "save_file", .{} }) catch {};
}
pub fn vcs_content_update(self: *const Self) !void {
_ = try self.handlers.msg(.{ "E", "update" });
}
fn send_editor_eol_mode(self: *const Self, eol_mode: Buffer.EolMode, utf8_sanitized: bool, indent_mode: IndentMode) !void {
_ = try self.handlers.msg(.{ "E", "eol_mode", eol_mode, utf8_sanitized, indent_mode });
}

View file

@ -1976,5 +1976,7 @@ pub fn vcs_content_update(self: *Self, m: tp.message) void {
if (m.match(.{ "PRJ", "vcs_content", tp.extract(&file_path), tp.extract(&vcs_id), tp.extract(&content) }) catch return) {
const buffer = self.buffer_manager.get_buffer_for_file(file_path) orelse return;
buffer.set_vcs_content(vcs_id, content) catch {};
if (self.get_editor_for_buffer(buffer)) |editor|
editor.vcs_content_update() catch {};
}
}