diff --git a/macos/Sources/Ghostty/Ghostty.Input.swift b/macos/Sources/Ghostty/Ghostty.Input.swift index 43bf8d096..0a279ea1f 100644 --- a/macos/Sources/Ghostty/Ghostty.Input.swift +++ b/macos/Sources/Ghostty/Ghostty.Input.swift @@ -50,7 +50,8 @@ extension Ghostty { } case GHOSTTY_TRIGGER_UNICODE: - equiv = String(trigger.key.unicode) + guard let scalar = UnicodeScalar(trigger.key.unicode) else { return nil } + equiv = String(scalar) default: return nil diff --git a/src/input/Binding.zig b/src/input/Binding.zig index fa719d981..a467bfc2b 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -1454,21 +1454,30 @@ pub const Set = struct { }; // If we have any leaders we need to clone them. - var it = result.bindings.iterator(); - while (it.next()) |entry| switch (entry.value_ptr.*) { - // Leaves could have data to clone (i.e. text actions - // contain allocated strings). - .leaf => |*s| s.* = try s.clone(alloc), + { + var it = result.bindings.iterator(); + while (it.next()) |entry| switch (entry.value_ptr.*) { + // Leaves could have data to clone (i.e. text actions + // contain allocated strings). + .leaf => |*s| s.* = try s.clone(alloc), - // Must be deep cloned. - .leader => |*s| { - const ptr = try alloc.create(Set); - errdefer alloc.destroy(ptr); - ptr.* = try s.*.clone(alloc); - errdefer ptr.deinit(alloc); - s.* = ptr; - }, - }; + // Must be deep cloned. + .leader => |*s| { + const ptr = try alloc.create(Set); + errdefer alloc.destroy(ptr); + ptr.* = try s.*.clone(alloc); + errdefer ptr.deinit(alloc); + s.* = ptr; + }, + }; + } + + // We need to clone the action keys in the reverse map since + // they may contain allocated values. + { + var it = result.reverse.keyIterator(); + while (it.next()) |action| action.* = try action.clone(alloc); + } return result; }