patch 8.1.2053: SafeStateAgain not triggered if callback uses feedkeys()
Problem: SafeStateAgain not triggered if callback uses feedkeys().
Solution: Check for safe state in the input loop. Make log messages easier
to find. Add 'S' flag to state().
diff --git a/src/getchar.c b/src/getchar.c
index 93d0d64..1056e93 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -933,7 +933,7 @@
init_typebuf();
if (++typebuf.tb_change_cnt == 0)
typebuf.tb_change_cnt = 1;
- state_no_longer_safe();
+ state_no_longer_safe("ins_typebuf()");
addlen = (int)STRLEN(str);
@@ -1797,7 +1797,7 @@
// Need to process the character before we know it's safe to do something
// else.
if (c != K_IGNORE)
- state_no_longer_safe();
+ state_no_longer_safe("key typed");
return c;
}
@@ -2047,6 +2047,7 @@
int i;
int save_may_garbage_collect = may_garbage_collect;
static int entered = 0;
+ int was_safe = get_was_safe_state();
// Do not handle messages while redrawing, because it may cause buffers to
// change or be wiped while they are being redrawn.
@@ -2102,7 +2103,7 @@
// When not nested we'll go back to waiting for a typed character. If it
// was safe before then this triggers a SafeStateAgain autocommand event.
- if (entered == 1)
+ if (entered == 1 && was_safe)
may_trigger_safestateagain();
may_garbage_collect = save_may_garbage_collect;