Skip to content

Commit 37d1807

Browse files
committed
patch 8.1.2048: not clear why SafeState and SafeStateAgain are not triggered
Problem: Not clear why SafeState and SafeStateAgain are not triggered. Solution: Add log statements.
1 parent 0e57dd8 commit 37d1807

4 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/getchar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ parse_queued_messages(void)
21032103
// When not nested we'll go back to waiting for a typed character. If it
21042104
// was safe before then this triggers a SafeStateAgain autocommand event.
21052105
if (entered == 1)
2106-
leave_unsafe_state();
2106+
may_trigger_safestateagain();
21072107

21082108
may_garbage_collect = save_may_garbage_collect;
21092109

src/main.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,11 @@ may_trigger_safestate(int safe)
10611061
&& scriptin[curscript] == NULL
10621062
&& !global_busy;
10631063

1064+
if (was_safe != is_safe)
1065+
// Only log when the state changes, otherwise it happens at nearly
1066+
// every key stroke.
1067+
ch_log(NULL, is_safe ? "Start triggering SafeState"
1068+
: "Stop triggering SafeState");
10641069
if (is_safe)
10651070
apply_autocmds(EVENT_SAFESTATE, NULL, NULL, FALSE, curbuf);
10661071
was_safe = is_safe;
@@ -1074,6 +1079,8 @@ may_trigger_safestate(int safe)
10741079
void
10751080
state_no_longer_safe(void)
10761081
{
1082+
if (was_safe)
1083+
ch_log(NULL, "safe state reset");
10771084
was_safe = FALSE;
10781085
}
10791086

@@ -1082,10 +1089,15 @@ state_no_longer_safe(void)
10821089
* SafeStateAgain, if it was safe when starting to wait for a character.
10831090
*/
10841091
void
1085-
leave_unsafe_state(void)
1092+
may_trigger_safestateagain(void)
10861093
{
10871094
if (was_safe)
1095+
{
1096+
ch_log(NULL, "Leaving unsafe area, triggering SafeStateAgain");
10881097
apply_autocmds(EVENT_SAFESTATEAGAIN, NULL, NULL, FALSE, curbuf);
1098+
}
1099+
else
1100+
ch_log(NULL, "Leaving unsafe area, not triggering SafeStateAgain");
10891101
}
10901102

10911103

src/proto/main.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ int is_not_a_term(void);
55
int op_pending(void);
66
void may_trigger_safestate(int safe);
77
void state_no_longer_safe(void);
8-
void leave_unsafe_state(void);
8+
void may_trigger_safestateagain(void);
99
void main_loop(int cmdwin, int noexmode);
1010
void getout_preserve_modified(int exitval);
1111
void getout(int exitval);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ static char *(features[]) =
757757

758758
static int included_patches[] =
759759
{ /* Add new patch number below this line */
760+
/**/
761+
2048,
760762
/**/
761763
2047,
762764
/**/

0 commit comments

Comments
 (0)