diff --git a/src/keybind/dynamic/keybind.zig b/src/keybind/dynamic/keybind.zig index 399b770..df7c190 100644 --- a/src/keybind/dynamic/keybind.zig +++ b/src/keybind/dynamic/keybind.zig @@ -134,7 +134,7 @@ pub fn parse_key_events(allocator: std.mem.Allocator, str: []const u8) ![]KeyEve state = .escape_sequence_start; i += 1; }, - 'a'...'z', ';', '0'...'9' => { + 'a'...'z', '\\', '[', ']', '/', '`', '-', '=', ';', '0'...'9' => { try result.append(.{ .key = str[i] }); i += 1; }, @@ -608,6 +608,12 @@ const BindingSet = struct { for (self.bindings.items) |binding| blk: { switch (binding.match(self.current_sequence.items)) { .matched => { + errdefer { + //clear current sequence if command execution fails + self.current_sequence.clearRetainingCapacity(); + self.current_sequence_egc.clearRetainingCapacity(); + } + if (!builtin.is_test) { self.logger.print("matched binding -> {s}", .{binding.command}); if (!builtin.is_test) self.logger.print("execute '{s}'", .{binding.command}); diff --git a/src/keybind/dynamic/keybindings.json b/src/keybind/dynamic/keybindings.json index 32c3272..66765fd 100644 --- a/src/keybind/dynamic/keybindings.json +++ b/src/keybind/dynamic/keybindings.json @@ -3,14 +3,26 @@ "normal": { "on_match_failure": "ignore", "bindings": [ - ["j", "cursor_down"], - ["k", "cursor_up"], - ["h", "cursor_right_vim"], - ["l", "cursor_left_vim"], - ["i", "change_mode", "insert"], - ["o", "change_mode", "insert"], - ["a", "change_mode", "insert"], - ["v", "change_mode", "visual"], + ["j", "move_down"], + ["k", "move_up"], + ["l", "move_right_vim"], + ["h", "move_left"], + ["", "move_right_vim"], + + ["i", "enter_mode", "insert"], + ["v", "enter_mode", "visual"], + + ["/", "find"], + ["n", "goto_next_match"], + + ["0", "move_begin"], + ["", "move_end"], + + [";", "open_command_palette"], + ["", "open_command_palette"], + + ["p", "paste"], + ["gg", "goto_page_begin"], ["", "goto_page_end"], ["", "cursor_half_page_up"], @@ -20,8 +32,8 @@ "insert": { "on_match_failure": "insert", "bindings": [ - ["jk", "change_mode", "normal"], - ["", "change_mode", "normal"] + ["jk", "enter_mode", "normal"], + ["", "enter_mode", "normal"] ] } },