// 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)
- leave_unsafe_state();
+ may_trigger_safestateagain();
may_garbage_collect = save_may_garbage_collect;
&& scriptin[curscript] == NULL
&& !global_busy;
+ if (was_safe != is_safe)
+ // Only log when the state changes, otherwise it happens at nearly
+ // every key stroke.
+ ch_log(NULL, is_safe ? "Start triggering SafeState"
+ : "Stop triggering SafeState");
if (is_safe)
apply_autocmds(EVENT_SAFESTATE, NULL, NULL, FALSE, curbuf);
was_safe = is_safe;
void
state_no_longer_safe(void)
{
+ if (was_safe)
+ ch_log(NULL, "safe state reset");
was_safe = FALSE;
}
* SafeStateAgain, if it was safe when starting to wait for a character.
*/
void
-leave_unsafe_state(void)
+may_trigger_safestateagain(void)
{
if (was_safe)
+ {
+ ch_log(NULL, "Leaving unsafe area, triggering SafeStateAgain");
apply_autocmds(EVENT_SAFESTATEAGAIN, NULL, NULL, FALSE, curbuf);
+ }
+ else
+ ch_log(NULL, "Leaving unsafe area, not triggering SafeStateAgain");
}
int op_pending(void);
void may_trigger_safestate(int safe);
void state_no_longer_safe(void);
-void leave_unsafe_state(void);
+void may_trigger_safestateagain(void);
void main_loop(int cmdwin, int noexmode);
void getout_preserve_modified(int exitval);
void getout(int exitval);