fix: make create_scratch_buffer work correctly across splits

This commit is contained in:
CJ van den Berg 2026-01-20 16:16:32 +01:00
parent dd0e108f76
commit a532665afb
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -724,6 +724,21 @@ const cmds = struct {
const args = try ctx.args.clone(self.allocator); const args = try ctx.args.clone(self.allocator);
defer self.allocator.free(args.buf); defer self.allocator.free(args.buf);
tui.reset_drag_context(); 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 self.create_editor();
try command.executeName("open_scratch_buffer", .{ .args = args }); try command.executeName("open_scratch_buffer", .{ .args = args });
tui.need_render(@src()); tui.need_render(@src());