diff --git a/src/config/Config.zig b/src/config/Config.zig index 5b1d73deb..9e6e5629c 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -2880,9 +2880,16 @@ keybind: Keybinds = .{}, /// command-palette-entry = title:"Ghostty",description:"Add a little Ghostty to your terminal.",action:"text:\xf0\x9f\x91\xbb" /// ``` /// +/// There are some additional special values that can be specified for +/// command-palette-entry: +/// +/// * `command-palette-entry=clear` will clear all command entries. Warning: this +/// removes ALL entries up to this point, including the default +/// entries. Available since: 1.4.0 +/// /// By default, the command palette is preloaded with most actions that might /// be useful in an interactive setting yet do not have easily accessible or -/// memorizable shortcuts. The default entries can be cleared by setting this +/// memorizable shortcuts. The default entries can be restored by setting this /// setting to an empty value: /// /// ```ini @@ -8736,6 +8743,13 @@ pub const RepeatableCommand = struct { // Unset or empty input clears the list const input = input_ orelse ""; if (input.len == 0) { + log.info("config has 'command-palette-entry =', using default entries", .{}); + try self.init(alloc); + return; + } + + if (std.mem.eql(u8, input, "clear")) { + log.info("config has 'command-palette-entry = clear', all command entries cleared", .{}); self.value.clearRetainingCapacity(); self.value_c.clearRetainingCapacity(); return; @@ -8847,8 +8861,11 @@ pub const RepeatableCommand = struct { try testing.expectEqualStrings("Baz", list.value.items[3].title); try testing.expectEqualStrings("Raspberry Pie", list.value.items[3].description); - try list.parseCLI(alloc, ""); + try list.parseCLI(alloc, "clear"); try testing.expectEqual(@as(usize, 0), list.value.items.len); + + try list.parseCLI(alloc, ""); + try testing.expectEqual(inputpkg.command.defaults.len, list.value.items.len); } test "RepeatableCommand formatConfig empty" { @@ -8963,7 +8980,7 @@ pub const RepeatableCommand = struct { try list.parseCLI(alloc, "title:Foo,action:ignore"); try testing.expectEqual(@as(usize, 1), list.cval().len); - try list.parseCLI(alloc, ""); + try list.parseCLI(alloc, "clear"); try testing.expectEqual(@as(usize, 0), list.cval().len); } };