From 845bcdb498da4d2e3552ffb9385ed8c9b7fc5218 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 20 Dec 2025 15:11:08 -0800 Subject: [PATCH] config: copy key table name into arena --- src/Surface.zig | 11 +++++++++-- src/config/Config.zig | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 2254b287c..af7cdf136 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -5609,15 +5609,20 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool .activate_key_table_once, => |name, tag| { // Look up the table in our config - const set = self.config.keybind.tables.getPtr(name) orelse + const set = self.config.keybind.tables.getPtr(name) orelse { + log.debug("key table not found: {s}", .{name}); return false; + }; // If this is the same table as is currently active, then // do nothing. if (self.keyboard.table_stack.items.len > 0) { const items = self.keyboard.table_stack.items; const active = items[items.len - 1].set; - if (active == set) return false; + if (active == set) { + log.debug("ignoring duplicate activate table: {s}", .{name}); + return false; + } } // Add the table to the stack. @@ -5625,6 +5630,8 @@ pub fn performBindingAction(self: *Surface, action: input.Binding.Action) !bool .set = set, .once = tag == .activate_key_table_once, }); + + log.debug("key table activated: {s}", .{name}); }, .deactivate_key_table => switch (self.keyboard.table_stack.items.len) { diff --git a/src/config/Config.zig b/src/config/Config.zig index 17b4275b0..c0d8e813e 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -6610,6 +6610,9 @@ pub const Keybinds = struct { // Get or create the table const gop = try self.tables.getOrPut(alloc, table_name); if (!gop.found_existing) { + // We need to copy our table name into the arena + // for valid lookups later. + gop.key_ptr.* = try alloc.dupe(u8, table_name); gop.value_ptr.* = .{}; } @@ -6636,7 +6639,8 @@ pub const Keybinds = struct { try tables.ensureTotalCapacity(alloc, @intCast(self.tables.count())); var it = self.tables.iterator(); while (it.next()) |entry| { - tables.putAssumeCapacity(entry.key_ptr.*, try entry.value_ptr.clone(alloc)); + const key = try alloc.dupe(u8, entry.key_ptr.*); + tables.putAssumeCapacity(key, try entry.value_ptr.clone(alloc)); } return .{