Mercurial > vim
diff src/main.c @ 18102:0d9ec3a2821f v8.1.2046
patch 8.1.2046: SafeState may be triggered at the wrong moment
Commit: https://github.com/vim/vim/commit/69198cb8c08f124729c41a4681f2d142228a9139
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 16 21:58:13 2019 +0200
patch 8.1.2046: SafeState may be triggered at the wrong moment
Problem: SafeState may be triggered at the wrong moment.
Solution: Move it up higher to after where messages are processed. Add a
SafeStateAgain event to tigger there.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Sep 2019 22:00:04 +0200 |
parents | a2870e6f5b45 |
children | e59ff7b5d7a7 |
line wrap: on
line diff
--- a/src/main.c +++ b/src/main.c @@ -1029,8 +1029,8 @@ is_not_a_term() } +// When TRUE in a safe state when starting to wait for a character. static int was_safe = FALSE; -static int not_safe_now = 0; /* * Trigger SafeState if currently in a safe state for main_loop(). @@ -1057,6 +1057,7 @@ may_trigger_safestate(int safe) int is_safe = safe && stuff_empty() && typebuf.tb_len == 0 + && scriptin[curscript] == NULL && !global_busy; if (is_safe) @@ -1065,24 +1066,25 @@ may_trigger_safestate(int safe) } /* - * Entering a not-safe state. + * Something changed which causes the state possibly to be unsafe, e.g. a + * character was typed. It will remain unsafe until the next call to + * may_trigger_safestate(). */ void -enter_unsafe_state(void) +state_no_longer_safe(void) { - ++not_safe_now; + was_safe = FALSE; } /* - * Leaving a not-safe state. Trigger SafeState if we were in a safe state - * before first calling enter_not_safe_state(). + * Invoked when leaving code that invokes callbacks. Then trigger + * SafeStateAgain, if it was safe when starting to wait for a character. */ void leave_unsafe_state(void) { - --not_safe_now; - if (not_safe_now == 0 && was_safe) - apply_autocmds(EVENT_SAFESTATE, NULL, NULL, FALSE, curbuf); + if (was_safe) + apply_autocmds(EVENT_SAFESTATEAGAIN, NULL, NULL, FALSE, curbuf); }