From 9997739b96a7fc142a18cb72cb7589bd4b4d61b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 16 Dec 2016 12:37:55 +0100 Subject: vis: change key input handling model Previously if you had a mapping for both `a` and `ab` the latter would in effect be unreachable because the greedy search would always match and then execute the former. With the new behavior we keep reading keys until we have a non ambigious sequence. That is after pressing `a` nothing will happen, if the next key is a `b` we will execute the `ab` mapping otherwise we will perform `a` and whatever the action is for the next key. Close #386 --- vis-modes.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'vis-modes.c') diff --git a/vis-modes.c b/vis-modes.c index f28856b..8df7b16 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -121,8 +121,8 @@ static bool mode_map(Vis *vis, Mode *mode, bool force, const char *key, const Ke if (!mode->bindings && !(mode->bindings = map_new())) return false; if (force) - map_prefix_delete(mode->bindings, key); - return (strcmp(key, "<") == 0 || !map_contains(mode->bindings, key)) && map_put(mode->bindings, key, binding); + map_delete(mode->bindings, key); + return map_put(mode->bindings, key, binding); } bool vis_mode_map(Vis *vis, enum VisMode id, bool force, const char *key, const KeyBinding *binding) { -- cgit v1.2.3