From 6adb9ea0a6ca01414f4b591f379b0f829a8273c0 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 30 Apr 2020 22:31:18 +0200 Subject: 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. --- src/ex_getln.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/ex_getln.c') diff --git a/src/ex_getln.c b/src/ex_getln.c index 6376a5fba4..48d40cfc76 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -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) { -- cgit v1.2.3