vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit ca17f01829d779272e84f5878c13637002b7a9bc parent 457cfef9226696b3dae6e34bc8e0749ae0a6ef98 Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 16 Nov 2016 23:42:26 +0100 vis: treat vis_keys_feed input like a macro replay We need to push keys individually to the input queue such that the state machine can advance and record keys into the operator macro if necessary. Previously feeding the following input: isome text<Escape>. would not work as expected because the complete key stream was pushed to the input queue at the same time during which the operator macro was not yet active. Thus the dot command at the end would have nothing to repeat. Diffstat:
| M | vis-core.h | | | 1 | + |
| M | vis.c | | | 9 | ++++++++- |
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/vis-core.h b/vis-core.h @@ -89,6 +89,7 @@ typedef struct { /* a macro is just a sequence of symbolic keys as received from ui->getkey */ typedef Buffer Macro; +#define macro_init buffer_init #define macro_release buffer_release #define macro_reset buffer_truncate #define macro_append buffer_append0 diff --git a/vis.c b/vis.c @@ -930,7 +930,14 @@ static void vis_keys_process(Vis *vis, size_t pos) { } void vis_keys_feed(Vis *vis, const char *input) { - vis_keys_push(vis, input, buffer_length0(vis->keys), false); + if (!input) + return; + Macro macro; + macro_init(¯o); + if (!macro_append(¯o, input)) + return; + macro_replay(vis, ¯o); + macro_release(¯o); } static void vis_keys_push(Vis *vis, const char *input, size_t pos, bool record) {