diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 11:11:02 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-08-21 14:16:16 +0800 |
commit | 4956f267449ca7526145c63ef095bfd731174635 (patch) | |
tree | 5933bdab52411f2905002f2566559725807a62b9 /src/nvim/normal.c | |
parent | ab45d5bf6d46abd9b29389dee6689044fd63e225 (diff) | |
download | rneovim-4956f267449ca7526145c63ef095bfd731174635.tar.gz rneovim-4956f267449ca7526145c63ef095bfd731174635.tar.bz2 rneovim-4956f267449ca7526145c63ef095bfd731174635.zip |
vim-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.
https://github.com/vim/vim/commit/69198cb8c08f124729c41a4681f2d142228a9139
SafeStateAgain is N/A.
Move SafeState functions to state.c.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r-- | src/nvim/normal.c | 36 |
1 files changed, 1 insertions, 35 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 253a3f288e..324bfc0c46 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -482,40 +482,6 @@ bool check_text_or_curbuf_locked(oparg_T *oap) return true; } -static bool was_safe = false; -static int not_safe_now = 0; - -/// Trigger SafeState if currently in s safe state, that is "safe" is TRUE and -/// there is no typeahead. -void may_trigger_safestate(bool safe) -{ - bool is_safe = safe - && stuff_empty() - && typebuf.tb_len == 0 - && !global_busy; - - if (is_safe) { - apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); - } - was_safe = is_safe; -} - -/// Entering a not-safe state. -void enter_unsafe_state(void) -{ - not_safe_now++; -} - -/// Leaving a not-safe state. Trigger SafeState if we were in a safe state -/// before first calling enter_not_safe_state(). -void leave_unsafe_state(void) -{ - not_safe_now--; - if (not_safe_now == 0 && was_safe) { - apply_autocmds(EVENT_SAFESTATE, NULL, NULL, false, curbuf); - } -} - /// Normal state entry point. This is called on: /// /// - Startup, In this case the function never returns. @@ -1434,7 +1400,7 @@ static int normal_check(VimState *state) quit_more = false; // it's not safe unless normal_check_safe_state() is called - was_safe = false; + state_no_longer_safe(); // If skip redraw is set (for ":" in wait_return()), don't redraw now. // If there is nothing in the stuff_buffer or do_redraw is true, |