0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

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.
This commit is contained in:
Bram Moolenaar
2020-04-30 22:31:18 +02:00
parent 4e5534fab7
commit 6adb9ea0a6
18 changed files with 67 additions and 43 deletions

View File

@@ -1318,12 +1318,12 @@ getcmdline_int(
c = get_expr_register();
if (c == '=')
{
// Need to save and restore ccline. And set "textlock"
// Need to save and restore ccline. And set "textwinlock"
// to avoid nasty things like going to another buffer when
// evaluating an expression.
++textlock;
++textwinlock;
p = get_expr_line();
--textlock;
--textwinlock;
if (p != NULL)
{
@@ -2548,17 +2548,17 @@ check_opt_wim(void)
/*
* Return TRUE when the text must not be changed and we can't switch to
* another window or buffer. Used when editing the command line, evaluating
* another window or buffer. TRUE when editing the command line, evaluating
* 'balloonexpr', etc.
*/
int
text_locked(void)
text_and_win_locked(void)
{
#ifdef FEAT_CMDWIN
if (cmdwin_type != 0)
return TRUE;
#endif
return textlock != 0;
return textwinlock != 0;
}
/*
@@ -2578,9 +2578,21 @@ get_text_locked_msg(void)
if (cmdwin_type != 0)
return e_cmdwin;
#endif
if (textwinlock != 0)
return e_textwinlock;
return e_textlock;
}
/*
* Return TRUE when the text must not be changed and/or we cannot switch to
* another window. TRUE while evaluating 'completefunc'.
*/
int
text_locked(void)
{
return text_and_win_locked() || textlock != 0;
}
/*
* Check if "curbuf_lock" or "allbuf_lock" is set and return TRUE when it is
* and give an error message.
@@ -3560,11 +3572,11 @@ cmdline_paste(
regname = may_get_selection(regname);
#endif
// Need to set "textlock" to avoid nasty things like going to another
// Need to set "textwinlock" to avoid nasty things like going to another
// buffer when evaluating an expression.
++textlock;
++textwinlock;
i = get_spec_reg(regname, &arg, &allocated, TRUE);
--textlock;
--textwinlock;
if (i)
{