patch 8.2.0670: cannot change window when evaluating 'completefunc'
Problem: Cannot change window when evaluating 'completefunc'.
Solution: Make a difference between not changing text or buffers and also
not changing window.
diff --git a/src/insexpand.c b/src/insexpand.c
index 48ab260..bd809b0 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -989,9 +989,9 @@
dict_set_items_ro(v_event);
recursive = TRUE;
- textlock++;
+ textwinlock++;
apply_autocmds(EVENT_COMPLETECHANGED, NULL, NULL, FALSE, curbuf);
- textlock--;
+ textwinlock--;
recursive = FALSE;
dict_free_contents(v_event);
@@ -2217,7 +2217,8 @@
pos = curwin->w_cursor;
curwin_save = curwin;
curbuf_save = curbuf;
- // Lock the text to avoid weird things from happening.
+ // Lock the text to avoid weird things from happening. Do allow switching
+ // to another window temporarily.
++textlock;
// Call a function, which returns a list or dict.
@@ -2442,8 +2443,8 @@
return;
}
- // "textlock" is set when evaluating 'completefunc' but we can change text
- // here.
+ // "textlock" is set when evaluating 'completefunc' but we can change
+ // text here.
textlock = 0;
// Check for undo allowed here, because if something was already inserted