diff --git a/src/command.zig b/src/command.zig index e086e47..0a23742 100644 --- a/src/command.zig +++ b/src/command.zig @@ -18,20 +18,11 @@ pub const Context = struct { cbor.writeValue(&context_buffer.writer, value) catch @panic("command.Context.fmt failed"); return .{ .args = .{ .buf = context_buffer.written() } }; } - - fn fmtbuf(buf: []u8, value: anytype) error{CommandContextBufferNoSpaceLeft}!Context { - var writer: std.Io.Writer = .fixed(buf); - cbor.writeValue(&writer, value) catch |e| return switch (e) { - error.WriteFailed => error.CommandContextBufferNoSpaceLeft, - }; - return .{ .args = .{ .buf = writer.buffered() } }; - } }; const context_buffer_allocator = std.heap.c_allocator; threadlocal var context_buffer: std.Io.Writer.Allocating = .init(context_buffer_allocator); pub const fmt = Context.fmt; -pub const fmtbuf = Context.fmtbuf; const Vtable = struct { id: ID = ID_unknown, diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 3ac429f..76f8556 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -724,21 +724,6 @@ const cmds = struct { const args = try ctx.args.clone(self.allocator); defer self.allocator.free(args.buf); tui.reset_drag_context(); - - var file_path: []const u8 = undefined; - if (ctx.args.match(.{ tp.extract(&file_path), tp.string, tp.string }) catch false or - ctx.args.match(.{ tp.extract(&file_path), tp.string }) catch false or - ctx.args.match(.{tp.extract(&file_path)}) catch false) - { - if (self.buffer_manager.get_buffer_for_file(file_path)) |_| { - var buf: [tp.max_message_size]u8 = undefined; - try command.executeName("navigate", try command.fmtbuf(&buf, .{ .file = file_path })); - tui.need_render(@src()); - self.location_update_from_editor(); - return; - } - } - try self.create_editor(); try command.executeName("open_scratch_buffer", .{ .args = args }); tui.need_render(@src()); diff --git a/src/tui/tui.zig b/src/tui/tui.zig index a26e6e0..8c205c2 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1354,8 +1354,7 @@ const cmds = struct { defer buffer_name.deinit(); buffer_name.writer.print("*{s}*", .{cmd}) catch {}; call_add_task(task); - var buf: [tp.max_message_size]u8 = undefined; - try command.executeName("create_scratch_buffer", try command.fmtbuf(&buf, .{ buffer_name.written(), "", "conf" })); + tp.self_pid().send(.{ "cmd", "create_scratch_buffer", .{ buffer_name.written(), "", "conf" } }) catch |e| self.logger.err("task", e); tp.self_pid().send(.{ "cmd", "shell_execute_stream", .{cmd} }) catch |e| self.logger.err("task", e); } else { return self.enter_overlay_mode(@import("mode/overlay/task_palette.zig").Type);