From 1f0de12f98e1937bd749e3060f91a2de0206fcb3 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 10 May 2024 20:58:17 +0200 Subject: [PATCH] input: fix builtin sequence bindings 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. --- input/input.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/input/input.c b/input/input.c index fe7bb00fbf902..c9e235ebd90bd 100644 --- a/input/input.c +++ b/input/input.c @@ -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]; @@ -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: ; }