Skip to content

Commit

Permalink
input: fix builtin sequence bindings
Browse files Browse the repository at this point in the history
If g-p is a builtin binding and p is bound in input.conf, pressing g-p
triggers the p binding. Fix this by searching for builting bindings that
match a longer key sequence even after a user-defined binding has been
found.

Even after changing the condition from >= to > bindings of the same key
defined later in input.conf are still preferred over earlier ones,
because bind_keys() overwrites duplicate bindings. Bindings defined by
later mp.add_key_binding calls are also still preferred.
  • Loading branch information
guidocella committed May 10, 2024
1 parent 2887335 commit 1f0de12
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions input/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,
for (int builtin = 0; builtin < 2; builtin++) {
if (builtin && !ictx->opts->default_bindings)
break;
if (best)
break;
for (int n = 0; n < bs->num_binds; n++) {
if (bs->binds[n].is_builtin == (bool)builtin) {
struct cmd_bind *b = &bs->binds[n];
Expand All @@ -418,7 +416,7 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx,
if (b->keys[i] != keys[b->num_keys - 1 - i])
goto skip;
}
if (!best || b->num_keys >= best->num_keys)
if (!best || b->num_keys > best->num_keys)
best = b;
skip: ;
}
Expand Down

0 comments on commit 1f0de12

Please sign in to comment.