Compare commits
4 commits
8546c6ca14
...
0143a7148a
| Author | SHA1 | Date | |
|---|---|---|---|
| 0143a7148a | |||
| a561de6602 | |||
| 95e42d2c78 | |||
| 081ff6ec4f |
5 changed files with 32 additions and 3 deletions
|
|
@ -634,7 +634,6 @@ pub fn build_exe(
|
|||
.{ .name = "Buffer", .module = Buffer_mod },
|
||||
.{ .name = "keybind", .module = keybind_mod },
|
||||
.{ .name = "shell", .module = shell_mod },
|
||||
.{ .name = "git", .module = git_mod },
|
||||
.{ .name = "ripgrep", .module = ripgrep_mod },
|
||||
.{ .name = "theme", .module = themes_dep.module("theme") },
|
||||
.{ .name = "themes", .module = themes_dep.module("themes") },
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ ephemeral: bool = false,
|
|||
auto_save: bool = false,
|
||||
meta: ?[]const u8 = null,
|
||||
lsp_version: usize = 1,
|
||||
vcs_id: ?[]const u8 = null,
|
||||
vcs_content: ?[]const u8 = null,
|
||||
|
||||
undo_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 {
|
||||
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.file_buf) |buf| self.external_allocator.free(buf);
|
||||
if (self.leaves_buf) |buf| self.external_allocator.free(buf);
|
||||
|
|
|
|||
26
src/git.zig
26
src/git.zig
|
|
@ -268,6 +268,32 @@ pub fn new_or_modified_files(context_: usize) Error!void {
|
|||
}.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 {
|
||||
try git_err(context_, cmd, struct {
|
||||
fn result(context: usize, parent: tp.pid_ref, output: []const u8) void {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
_ = 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)
|
||||
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())
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
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());
|
||||
if (try m.match(.{ "E", "view", tp.extract(&self.lines), tp.extract(&self.view_rows), tp.extract(&self.view_top) }))
|
||||
return self.update_width();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue