vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 688cbb1ba399e3b4038ce8afb1a74b32bc88bcf1
parent eac198a579144c1435822b660326def95e9d67ee
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 10 Sep 2014 14:47:48 +0200

Add a few comments about the subtleties of mode switching

Diffstat:
Mconfig.def.h | 2++
Mvis.c | 7++++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h @@ -388,6 +388,8 @@ static KeyBinding vis_prompt_mode[] = { }; static void vis_prompt_leave(Mode *new) { + /* prompt mode may be left for operator mode when editing the command prompt. + * for example during Ctrl+w / delete_word. don't hide the prompt in this case */ if (new != &vis_modes[VIS_MODE_OPERATOR]) editor_prompt_hide(vis); } diff --git a/vis.c b/vis.c @@ -498,7 +498,8 @@ static void operator(const Arg *arg) { action_do(&action); return; } - + /* switch to operator mode inorder to make operator options and + * text-object available */ switchmode(&(const Arg){ .i = VIS_MODE_OPERATOR }); if (action.op == op) { /* hacky way to handle double operators i.e. things like @@ -587,6 +588,10 @@ static void prompt(const Arg *arg) { static void prompt_enter(const Arg *arg) { char *s = editor_prompt_get(vis); + /* it is important to switch to normal mode, which hides the prompt and + * more importantly resets vis->win to the currently focused editor + * window *before* anything is executed which depends on vis->win. + */ switchmode(&(const Arg){ .i = VIS_MODE_NORMAL }); switch (vis->prompt->title[0]) { case '/':