fix: allow editing the current editor's file type

This commit is contained in:
CJ van den Berg 2025-07-03 17:07:17 +02:00
parent 2897d8d745
commit a21fd2b397
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 4 additions and 4 deletions

View file

@ -6,7 +6,7 @@ const syntax = @import("syntax");
const Widget = @import("../../Widget.zig");
const tui = @import("../../tui.zig");
pub fn Variant(comptime command: []const u8, comptime label_: []const u8) type {
pub fn Variant(comptime command: []const u8, comptime label_: []const u8, allow_previous: bool) type {
return struct {
pub const Type = @import("palette.zig").Create(@This());
@ -125,7 +125,7 @@ pub fn Variant(comptime command: []const u8, comptime label_: []const u8) type {
if (!(cbor.matchString(&iter, &icon) catch false)) return;
if (!(cbor.matchInt(u24, &iter, &color) catch false)) return;
if (!(cbor.matchString(&iter, &name_) catch false)) return;
if (previous_file_type) |prev| if (std.mem.eql(u8, prev, name_))
if (!allow_previous) if (previous_file_type) |prev| if (std.mem.eql(u8, prev, name_))
return;
tp.self_pid().send(.{ "cmd", "exit_overlay_mode" }) catch |e| menu.*.opts.ctx.logger.err("file_type_palette", e);
tp.self_pid().send(.{ "cmd", command, .{name_} }) catch |e| menu.*.opts.ctx.logger.err("file_type_palette", e);