diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-16 12:37:55 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2017-01-16 19:46:07 +0100 |
| commit | 9997739b96a7fc142a18cb72cb7589bd4b4d61b0 (patch) | |
| tree | 58ec9864c78d917ecc3d70066dbc4c1dd2bda8b5 /vis-modes.c | |
| parent | 55f79e75f34ccf740d3f1c92ab35c604b067b01c (diff) | |
| download | vis-9997739b96a7fc142a18cb72cb7589bd4b4d61b0.tar.gz vis-9997739b96a7fc142a18cb72cb7589bd4b4d61b0.tar.xz | |
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
Diffstat (limited to 'vis-modes.c')
| -rw-r--r-- | vis-modes.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) { |
