]> granicus.if.org Git - vim/commitdiff
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered v8.1.2048
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Sep 2019 18:28:38 +0000 (20:28 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Sep 2019 18:28:38 +0000 (20:28 +0200)
Problem:    Not clear why SafeState and SafeStateAgain are not triggered.
Solution:   Add log statements.

src/getchar.c
src/main.c
src/proto/main.pro
src/version.c

index 3f3c6bca588a9d5c9ee7dbf5a6472346893aeb9d..93d0d64ee0b42efbd0f84951de6fc6eee3601b6e 100644 (file)
@@ -2103,7 +2103,7 @@ parse_queued_messages(void)
     // 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;
 
index 42aa9903434750b9b4d2c08e62577af8911bb825..ff3d2349ffd1abaa92a0fd4dffa76f4864f5af15 100644 (file)
@@ -1061,6 +1061,11 @@ may_trigger_safestate(int safe)
                    && 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;
@@ -1074,6 +1079,8 @@ may_trigger_safestate(int safe)
     void
 state_no_longer_safe(void)
 {
+    if (was_safe)
+       ch_log(NULL, "safe state reset");
     was_safe = FALSE;
 }
 
@@ -1082,10 +1089,15 @@ state_no_longer_safe(void)
  * 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");
 }
 
 
index caf435e40ab55408344c041e13146e2b2e0962ce..873255d8f70fde64599104e8c673aef0b76c2cac 100644 (file)
@@ -5,7 +5,7 @@ int is_not_a_term(void);
 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);
index 622f1687c811f83f89135ac7fe9644536fc58fa7..b8c88081d9b61be0571bb8909816e1d130712fe5 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2048,
 /**/
     2047,
 /**/