Compare commits

...

4 commits

5 changed files with 32 additions and 3 deletions

View file

@ -634,7 +634,6 @@ pub fn build_exe(
.{ .name = "Buffer", .module = Buffer_mod }, .{ .name = "Buffer", .module = Buffer_mod },
.{ .name = "keybind", .module = keybind_mod }, .{ .name = "keybind", .module = keybind_mod },
.{ .name = "shell", .module = shell_mod }, .{ .name = "shell", .module = shell_mod },
.{ .name = "git", .module = git_mod },
.{ .name = "ripgrep", .module = ripgrep_mod }, .{ .name = "ripgrep", .module = ripgrep_mod },
.{ .name = "theme", .module = themes_dep.module("theme") }, .{ .name = "theme", .module = themes_dep.module("theme") },
.{ .name = "themes", .module = themes_dep.module("themes") }, .{ .name = "themes", .module = themes_dep.module("themes") },

View file

@ -47,6 +47,8 @@ ephemeral: bool = false,
auto_save: bool = false, auto_save: bool = false,
meta: ?[]const u8 = null, meta: ?[]const u8 = null,
lsp_version: usize = 1, lsp_version: usize = 1,
vcs_id: ?[]const u8 = null,
vcs_content: ?[]const u8 = null,
undo_head: ?*UndoNode = null, undo_head: ?*UndoNode = null,
redo_head: ?*UndoNode = null, redo_head: ?*UndoNode = null,
@ -1191,6 +1193,8 @@ pub fn create(allocator: Allocator) error{OutOfMemory}!*Self {
} }
pub fn deinit(self: *Self) void { pub fn deinit(self: *Self) void {
if (self.vcs_content) |buf| self.external_allocator.free(buf);
if (self.vcs_id) |buf| self.external_allocator.free(buf);
if (self.meta) |buf| self.external_allocator.free(buf); if (self.meta) |buf| self.external_allocator.free(buf);
if (self.file_buf) |buf| self.external_allocator.free(buf); if (self.file_buf) |buf| self.external_allocator.free(buf);
if (self.leaves_buf) |buf| self.external_allocator.free(buf); if (self.leaves_buf) |buf| self.external_allocator.free(buf);

View file

@ -268,6 +268,32 @@ pub fn new_or_modified_files(context_: usize) Error!void {
}.result, exit_null(tag)); }.result, exit_null(tag));
} }
pub fn rev_parse(context_: usize, rev: []const u8, file_path: []const u8) Error!void {
const tag = @src().fn_name;
var arg: std.Io.Writer.Allocating = .init(allocator);
defer arg.deinit();
if (file_path.len == 0)
arg.writer.print("{s}", .{rev})
else
arg.writer.print("{s}:{s}", .{ rev, file_path });
try git(context_, .{ "rev-parse", arg.written() }, struct {
fn result(context: usize, parent: tp.pid_ref, output: []const u8) void {
var it = std.mem.splitScalar(u8, output, '\n');
while (it.next()) |value| if (value.len > 0)
parent.send(.{ module_name, context, tag, output }) catch {};
}
}.result, exit_null_on_error(tag));
}
pub fn cat_file(context_: usize, object: []const u8) Error!void {
const tag = @src().fn_name;
try git(context_, .{ "cat-file", "-p", object }, struct {
fn result(context: usize, parent: tp.pid_ref, output: []const u8) void {
parent.send(.{ module_name, context, tag, output }) catch {};
}
}.result, exit_null_on_error(tag));
}
fn git_line_output(context_: usize, comptime tag: []const u8, cmd: anytype) Error!void { fn git_line_output(context_: usize, comptime tag: []const u8, cmd: anytype) Error!void {
try git_err(context_, cmd, struct { try git_err(context_, cmd, struct {
fn result(context: usize, parent: tp.pid_ref, output: []const u8) void { fn result(context: usize, parent: tp.pid_ref, output: []const u8) void {

View file

@ -1847,7 +1847,7 @@ pub const Editor = struct {
} }
fn send_editor_update(self: *const Self, old_root: ?Buffer.Root, new_root: ?Buffer.Root, eol_mode: Buffer.EolMode) !void { fn send_editor_update(self: *const Self, old_root: ?Buffer.Root, new_root: ?Buffer.Root, eol_mode: Buffer.EolMode) !void {
_ = try self.handlers.msg(.{ "E", "update", token_from(new_root), token_from(old_root), @intFromEnum(eol_mode) }); _ = try self.handlers.msg(.{ "E", "update" });
if (self.buffer) |buffer| if (self.syntax) |_| if (self.file_path) |file_path| if (old_root != null and new_root != null) if (self.buffer) |buffer| if (self.syntax) |_| if (self.file_path) |file_path| if (old_root != null and new_root != null)
project_manager.did_change(file_path, buffer.lsp_version, try text_from_root(new_root, eol_mode), try text_from_root(old_root, eol_mode), eol_mode) catch {}; project_manager.did_change(file_path, buffer.lsp_version, try text_from_root(new_root, eol_mode), try text_from_root(old_root, eol_mode), eol_mode) catch {};
if (self.buffer) |b| if (b.is_auto_save() and !b.is_ephemeral()) if (self.buffer) |b| if (b.is_auto_save() and !b.is_ephemeral())

View file

@ -79,7 +79,7 @@ fn diff_symbols_clear(self: *Self) void {
} }
pub fn handle_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result { pub fn handle_event(self: *Self, _: tp.pid_ref, m: tp.message) tp.result {
if (try m.match(.{ "E", "update", tp.more })) if (try m.match(.{ "E", "update" }))
return self.diff_update() catch |e| return tp.exit_error(e, @errorReturnTrace()); return self.diff_update() catch |e| return tp.exit_error(e, @errorReturnTrace());
if (try m.match(.{ "E", "view", tp.extract(&self.lines), tp.extract(&self.view_rows), tp.extract(&self.view_top) })) if (try m.match(.{ "E", "view", tp.extract(&self.lines), tp.extract(&self.view_rows), tp.extract(&self.view_top) }))
return self.update_width(); return self.update_width();