To: vim_dev@googlegroups.com Subject: Patch 8.1.2048 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.2048 Problem: Not clear why SafeState and SafeStateAgain are not triggered. Solution: Add log statements. Files: src/getchar.c, src/main.c, src/proto/main.pro *** ../vim-8.1.2047/src/getchar.c 2019-09-16 21:58:08.792800986 +0200 --- src/getchar.c 2019-09-17 20:28:01.617000366 +0200 *************** *** 2103,2109 **** // 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_garbage_collect = save_may_garbage_collect; --- 2103,2109 ---- // 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) ! may_trigger_safestateagain(); may_garbage_collect = save_may_garbage_collect; *** ../vim-8.1.2047/src/main.c 2019-09-16 22:55:57.732006874 +0200 --- src/main.c 2019-09-17 20:27:58.081014164 +0200 *************** *** 1061,1066 **** --- 1061,1071 ---- && 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,1079 **** --- 1079,1086 ---- void state_no_longer_safe(void) { + if (was_safe) + ch_log(NULL, "safe state reset"); was_safe = FALSE; } *************** *** 1082,1091 **** * SafeStateAgain, if it was safe when starting to wait for a character. */ void ! leave_unsafe_state(void) { if (was_safe) apply_autocmds(EVENT_SAFESTATEAGAIN, NULL, NULL, FALSE, curbuf); } --- 1089,1103 ---- * SafeStateAgain, if it was safe when starting to wait for a character. */ 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"); } *** ../vim-8.1.2047/src/proto/main.pro 2019-09-16 22:55:57.732006874 +0200 --- src/proto/main.pro 2019-09-17 20:28:04.128990565 +0200 *************** *** 5,11 **** int op_pending(void); void may_trigger_safestate(int safe); void state_no_longer_safe(void); ! void leave_unsafe_state(void); void main_loop(int cmdwin, int noexmode); void getout_preserve_modified(int exitval); void getout(int exitval); --- 5,11 ---- int op_pending(void); void may_trigger_safestate(int safe); void state_no_longer_safe(void); ! void may_trigger_safestateagain(void); void main_loop(int cmdwin, int noexmode); void getout_preserve_modified(int exitval); void getout(int exitval); *** ../vim-8.1.2047/src/version.c 2019-09-16 22:55:57.732006874 +0200 --- src/version.c 2019-09-17 20:17:35.391574427 +0200 *************** *** 759,760 **** --- 759,762 ---- { /* Add new patch number below this line */ + /**/ + 2048, /**/ -- press CTRL-ALT-DEL for more information /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///