Make undo/redo app-targeted so it works with no windows

pull/7535/head
Mitchell Hashimoto 2025-06-06 13:35:31 -07:00
parent 5507ec0fc0
commit 3b77a16b63
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
3 changed files with 20 additions and 14 deletions

View File

@ -446,6 +446,9 @@ pub fn performAction(
.toggle_visibility => _ = try rt_app.performAction(.app, .toggle_visibility, {}),
.check_for_updates => _ = try rt_app.performAction(.app, .check_for_updates, {}),
.show_gtk_inspector => _ = try rt_app.performAction(.app, .show_gtk_inspector, {}),
.undo => _ = try rt_app.performAction(.app, .undo, {}),
.redo => _ = try rt_app.performAction(.app, .redo, {}),
}
}

View File

@ -3923,6 +3923,21 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
.{ .parent = self },
),
// Undo and redo both support both surface and app targeting.
// If we are triggering on a surface then we perform the
// action with the surface target.
.undo => return try self.rt_app.performAction(
.{ .surface = self },
.undo,
{},
),
.redo => return try self.rt_app.performAction(
.{ .surface = self },
.redo,
{},
),
else => try self.app.performAction(
self.rt_app,
action.scoped(.app).?,
@ -4337,18 +4352,6 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool
{},
),
.undo => return try self.rt_app.performAction(
.{ .surface = self },
.undo,
{},
),
.redo => return try self.rt_app.performAction(
.{ .surface = self },
.redo,
{},
),
.select_all => {
const sel = self.io.terminal.screen.selectAll();
if (sel) |s| {

View File

@ -980,6 +980,8 @@ pub const Action = union(enum) {
// These are app but can be special-cased in a surface context.
.new_window,
.undo,
.redo,
=> .app,
// Obviously surface actions.
@ -1020,8 +1022,6 @@ pub const Action = union(enum) {
.toggle_secure_input,
.toggle_command_palette,
.reset_window_size,
.undo,
.redo,
.crash,
=> .surface,