diff options
author | wm4 <wm4@nowhere> | 2014-04-19 14:31:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-04-19 14:31:54 +0200 |
commit | 14421f732b63ab35fc7a528be0db9bbd33464772 (patch) | |
tree | b07786b8d4d18282a12f94275d4fa7616bc6570b /input/input.c | |
parent | d9106779375288323b5c63bc2bab341515f8a60d (diff) | |
download | mpv-14421f732b63ab35fc7a528be0db9bbd33464772.tar.bz2 mpv-14421f732b63ab35fc7a528be0db9bbd33464772.tar.xz |
input: make key binds order-independent again
This is for the sake of multi-key commands again. This could break:
SPACE ignore
SPACE-SPACE command
while this worked:
SPACE-SPACE command
SPACE ignore
The reason being that if the shorter command was first in the list,
it would obviously match, and searching was stopped.
Diffstat (limited to 'input/input.c')
-rw-r--r-- | input/input.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/input/input.c b/input/input.c index 5e25dd9c38..5245fd8b63 100644 --- a/input/input.c +++ b/input/input.c @@ -393,10 +393,14 @@ static struct cmd_bind *find_bind_for_key_section(struct input_ctx *ictx, memcpy(keys, ictx->key_history, sizeof(keys)); key_buf_add(keys, code); + struct cmd_bind *best = NULL; + // Prefer user-defined keys over builtin bindings for (int builtin = 0; builtin < 2; builtin++) { if (builtin && !ictx->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]; @@ -406,12 +410,13 @@ 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; } - return b; + if (!best || b->num_keys >= best->num_keys) + best = b; skip: ; } } } - return NULL; + return best; } static struct cmd_bind *find_any_bind_for_key(struct input_ctx *ictx, |