From 031d57a54d6898acbee7dc7a1afd92f65e690056 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 18 Nov 2024 19:30:15 +0100 Subject: [PATCH] feat: always add a toggle_input_mode keybinding (f2) Even if it is not configured for the mode. This allows the user to switch to the next mode even if the mode could not be loaded/parsed properly. --- src/keybind/dynamic/keybind.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/keybind/dynamic/keybind.zig b/src/keybind/dynamic/keybind.zig index ba85245..78fe9c3 100644 --- a/src/keybind/dynamic/keybind.zig +++ b/src/keybind/dynamic/keybind.zig @@ -206,6 +206,11 @@ const BindingSet = struct { } fn load_json(self: *@This(), json_string: []const u8, namespace_name: []const u8, mode_name: []const u8) !void { + defer self.bindings.append(.{ + .keys = self.allocator.dupe(KeyEvent, &[_]KeyEvent{.{ .key = input.key.f2 }}) catch @panic("failed to add toggle_input_mode fallback"), + .command = self.allocator.dupe(u8, "toggle_input_mode") catch @panic("failed to add toggle_input_mode fallback"), + .args = "", + }) catch {}; const parsed = try std.json.parseFromSlice(std.json.Value, self.allocator, json_string, .{}); defer parsed.deinit(); if (parsed.value != .object) return error.NotAnObject;