mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-05-24 05:40:15 +00:00
config: clear command-palette-entry like keybind (#12682)
After #1368, `command-palette-entry=` will no longer clear the entries like the documentation says. Since i couldn't find an existing issue or discussion about this, I assume no one is actually using it. So I put 1.4.0 here, lemme know if you want to change it to 1.3.2. > I basically copied the `keybind` parsing code and doc.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user