From 090e9acdb744fdb8d6c7efcee41da74fcf7c542c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:08:29 -0300 Subject: modal, normal: the twelve prefix roles take config.zig's names (goto_prefix, find_char_fwd, register_prefix...), so normalInput reads every binding by the role's own name and roleBindingName, which mapped the twelve, goes Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/modal.zig | 68 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/modal.zig') diff --git a/src/modal.zig b/src/modal.zig index e123d468..71a9ddcb 100644 --- a/src/modal.zig +++ b/src/modal.zig @@ -5,18 +5,18 @@ pub const Normal = struct { pub const Role = enum { escape, - prefix_goto, - prefix_view, - prefix_match, - prefix_find_fwd, - prefix_find_back, - prefix_till_fwd, - prefix_till_back, - prefix_replace, - prefix_next, - prefix_prev, - prefix_register, - prefix_view_sticky, + goto_prefix, + view_prefix, + match_prefix, + find_char_fwd, + find_char_back, + till_char_fwd, + till_char_back, + replace_prefix, + next_prefix, + prev_prefix, + register_prefix, + view_prefix_sticky, goto_file_start, goto_last_line, @@ -490,7 +490,7 @@ pub const Normal = struct { }, .match => { if (state.match_sub == .none) { - if (key.has(.prefix_match)) { + if (key.has(.match_prefix)) { state.prefix = .none; return resultAction(.match_bracket); } @@ -554,21 +554,21 @@ pub const Normal = struct { } // Prefix setters retain the count for their continuation. - if (key.has(.prefix_goto)) return armPrefix(state, .goto, if (counted.explicit) count else 0); - if (key.has(.prefix_view)) return armPrefix(state, .view, if (counted.explicit) count else 0); - if (key.has(.prefix_view_sticky)) { + if (key.has(.goto_prefix)) return armPrefix(state, .goto, if (counted.explicit) count else 0); + if (key.has(.view_prefix)) return armPrefix(state, .view, if (counted.explicit) count else 0); + if (key.has(.view_prefix_sticky)) { state.sticky = true; return armPrefix(state, .view, 0); } - if (key.has(.prefix_find_fwd)) return armPrefix(state, .find_fwd, if (counted.explicit) count else 0); - if (key.has(.prefix_find_back)) return armPrefix(state, .find_back, if (counted.explicit) count else 0); - if (key.has(.prefix_till_fwd)) return armPrefix(state, .till_fwd, if (counted.explicit) count else 0); - if (key.has(.prefix_till_back)) return armPrefix(state, .till_back, if (counted.explicit) count else 0); - if (key.has(.prefix_replace)) return armPrefix(state, .replace, if (counted.explicit) count else 0); - if (key.has(.prefix_next)) return armPrefix(state, .next, if (counted.explicit) count else 0); - if (key.has(.prefix_prev)) return armPrefix(state, .prev, if (counted.explicit) count else 0); - if (key.has(.prefix_match)) return armPrefix(state, .match, 0); - if (key.has(.prefix_register)) return armPrefix(state, .register, if (counted.explicit) count else 0); + if (key.has(.find_char_fwd)) return armPrefix(state, .find_fwd, if (counted.explicit) count else 0); + if (key.has(.find_char_back)) return armPrefix(state, .find_back, if (counted.explicit) count else 0); + if (key.has(.till_char_fwd)) return armPrefix(state, .till_fwd, if (counted.explicit) count else 0); + if (key.has(.till_char_back)) return armPrefix(state, .till_back, if (counted.explicit) count else 0); + if (key.has(.replace_prefix)) return armPrefix(state, .replace, if (counted.explicit) count else 0); + if (key.has(.next_prefix)) return armPrefix(state, .next, if (counted.explicit) count else 0); + if (key.has(.prev_prefix)) return armPrefix(state, .prev, if (counted.explicit) count else 0); + if (key.has(.match_prefix)) return armPrefix(state, .match, 0); + if (key.has(.register_prefix)) return armPrefix(state, .register, if (counted.explicit) count else 0); if (key.has(.move_left)) return resultAction(.{ .move = .{ .motion = .left, .count = count } }); if (key.has(.move_right)) return resultAction(.{ .move = .{ .motion = .right, .count = count } }); @@ -672,7 +672,7 @@ pub const Normal = struct { const sequence = [_]Input{ input('1', &.{}), input('2', &.{}), - input('g', &.{ .prefix_goto, .goto_file_start }), + input('g', &.{ .goto_prefix, .goto_file_start }), input('j', &.{ .move_down, .goto_line_down, .view_scroll_down }), }; for (sequence[0 .. sequence.len - 1]) |key| { @@ -693,7 +693,7 @@ pub const Normal = struct { test "invalid continuations are ignored and clear prefix plus count" { var state: State = .{}; try std.testing.expectEqual(Result.pending, parse(&state, input('4', &.{}))); - try std.testing.expectEqual(Result.pending, parse(&state, input('g', &.{.prefix_goto}))); + try std.testing.expectEqual(Result.pending, parse(&state, input('g', &.{.goto_prefix}))); try std.testing.expectEqual(Result.ignored, parse(&state, input('?', &.{}))); try std.testing.expectEqual(State{}, state); try std.testing.expectEqualDeep(Result{ .action = .{ .move = .{ .motion = .down, .count = 1 } } }, parse(&state, input('j', &.{.move_down}))); @@ -701,29 +701,29 @@ pub const Normal = struct { test "literal arguments retain conflicting command characters" { var state: State = .{}; - try std.testing.expectEqual(Result.pending, parse(&state, input('f', &.{.prefix_find_fwd}))); + try std.testing.expectEqual(Result.pending, parse(&state, input('f', &.{.find_char_fwd}))); try std.testing.expectEqualDeep(Result{ .action = .{ .find = .{ .kind = .forward, .char = 'p', .count = 1 } } }, parse(&state, input('p', &.{.paste_after}))); - try std.testing.expectEqual(Result.pending, parse(&state, input('m', &.{.prefix_match}))); + try std.testing.expectEqual(Result.pending, parse(&state, input('m', &.{.match_prefix}))); try std.testing.expectEqual(Result.pending, parse(&state, input('r', &.{.surround_replace}))); - try std.testing.expectEqual(Result.pending, parse(&state, input('[', &.{.prefix_prev}))); - try std.testing.expectEqualDeep(Result{ .action = .{ .surround_replace = .{ .from = '[', .to = ']' } } }, parse(&state, input(']', &.{.prefix_next}))); + try std.testing.expectEqual(Result.pending, parse(&state, input('[', &.{.prev_prefix}))); + try std.testing.expectEqualDeep(Result{ .action = .{ .surround_replace = .{ .from = '[', .to = ']' } } }, parse(&state, input(']', &.{.next_prefix}))); try std.testing.expectEqual(State{}, state); } test "modified and special keys cannot satisfy literal continuations" { var state: State = .{}; - _ = parse(&state, input('r', &.{.prefix_replace})); + _ = parse(&state, input('r', &.{.replace_prefix})); try std.testing.expectEqual(Result.ignored, parse(&state, .{ .cp = 'x', .ctrl = true })); try std.testing.expectEqual(State{}, state); - _ = parse(&state, input('f', &.{.prefix_find_fwd})); + _ = parse(&state, input('f', &.{.find_char_fwd})); try std.testing.expectEqual(Result.ignored, parse(&state, .{ .cp = 0xF0001 })); try std.testing.expectEqual(State{}, state); } test "replace accepts a Unicode literal" { var state: State = .{}; - try std.testing.expectEqual(Result.pending, parse(&state, input('r', &.{.prefix_replace}))); + try std.testing.expectEqual(Result.pending, parse(&state, input('r', &.{.replace_prefix}))); try std.testing.expectEqualDeep(Result{ .action = .{ .replace_char = '界' } }, parse(&state, input('界', &.{}))); try std.testing.expectEqual(State{}, state); } -- cgit v1.3