diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-29 01:49:09 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-29 01:49:09 +0100 |
| commit | 59238a51667ab4f51f9fab8bd93f4b732462b3de (patch) | |
| tree | 79405254421e792f8b855c614062f139388250f6 | |
| parent | 4dcdb73c4b76a3413730649ddf4039ec964466b9 (diff) | |
| download | vis-59238a51667ab4f51f9fab8bd93f4b732462b3de.tar.gz vis-59238a51667ab4f51f9fab8bd93f4b732462b3de.tar.xz | |
vis: unmap all conflicting bindings of a forced map command
| -rw-r--r-- | vis-modes.c | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/vis-modes.c b/vis-modes.c index 68771ce..86c86f0 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -78,23 +78,8 @@ static bool mode_map(Vis *vis, Mode *mode, bool force, const char *key, const Ke return false; if (!mode->bindings && !(mode->bindings = map_new())) return false; - if (force) { - char *lhs = strdup(key), *next = lhs; - if (!lhs) - return false; - while (next) { - char tmp; - next = (char*)vis_keys_next(vis, next); - if (next) { - tmp = *next; - *next = '\0'; - } - mode_unmap(mode, lhs); - if (next) - *next = tmp; - } - free(lhs); - } + if (force) + map_prefix_delete(mode->bindings, key); return (strcmp(key, "<") == 0 || !map_contains(mode->bindings, key)) && map_put(mode->bindings, key, binding); } |
