diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 87bb11d..40783ce 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -512,7 +512,7 @@ const cmds = struct { pub fn change_file_type(_: *Self, _: Ctx) Result { return tui.open_overlay( - @import("mode/overlay/file_type_palette.zig").Variant("set_file_type", "Select file type").Type, + @import("mode/overlay/file_type_palette.zig").Variant("set_file_type", "Select file type", false).Type, ); } pub const change_file_type_meta: Meta = .{ .description = "Change file type" }; @@ -521,7 +521,7 @@ const cmds = struct { var file_type_name: []const u8 = undefined; if (!(ctx.args.match(.{tp.extract(&file_type_name)}) catch false)) return tui.open_overlay( - @import("mode/overlay/file_type_palette.zig").Variant("open_file_type_config", "Edit file type").Type, + @import("mode/overlay/file_type_palette.zig").Variant("open_file_type_config", "Edit file type", true).Type, ); const file_name = try get_file_type_config_file_path(self.allocator, file_type_name); diff --git a/src/tui/mode/overlay/file_type_palette.zig b/src/tui/mode/overlay/file_type_palette.zig index 56f3269..719abe3 100644 --- a/src/tui/mode/overlay/file_type_palette.zig +++ b/src/tui/mode/overlay/file_type_palette.zig @@ -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);