vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 60e3c2ac3048236eca0dc15cfddca4b9b7c325ac parent 01f4fe644e45b8a1c98650f38b2c51757069b3b8 Author: Marc André Tanner <mat@brain-dump.org> Date: Sat, 17 Dec 2016 10:41:20 +0100 vis: always remove consumed keys from input queue When given a mapping like: :map! insert >> ><>x> whose end is a prefix of another mapping we should still remove all already consumed keys from the input queue. Fixes #436 Diffstat:
| M | vis.c | | | 6 | +++--- |
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/vis.c b/vis.c @@ -909,10 +909,11 @@ static void vis_keys_process(Vis *vis, size_t pos) { } else if (binding->alias) { buffer_remove(buf, start - buf->data, end - start); buffer_insert0(buf, start - buf->data, binding->alias); - cur = start; + cur = end = start; } } else if (prefix) { /* incomplete key binding? */ cur = end; + end = start; } else { /* no keybinding */ KeyAction *action = NULL; if (start[0] == '<' && end[-1] == '>') { @@ -937,8 +938,7 @@ static void vis_keys_process(Vis *vis, size_t pos) { } } - if (!prefix) - buffer_remove(buf, keys - buf->data, end - keys); + buffer_remove(buf, keys - buf->data, end - keys); } void vis_keys_feed(Vis *vis, const char *input) {