summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-01-29 21:47:24 +0100
committerBram Moolenaar <Bram@vim.org>2021-01-29 21:47:24 +0100
commit3eb6bd9c2b36dcce471bfb543c8d5488f1dc17a4 (patch)
tree2752a07b909b085c3a23eb3810155254e1e0b546
parent28976e2accf11591c60e8a658a9e03544f0408b2 (diff)
patch 8.2.2427: can still switch windows for 'completefunc'v8.2.2427
Problem: Can still switch windows for 'completefunc'. Solution: Also disallow switching windows for other completions.
-rw-r--r--src/insexpand.c21
-rw-r--r--src/testdir/test_ins_complete.vim2
-rw-r--r--src/testdir/test_popup.vim6
-rw-r--r--src/version.c2
4 files changed, 7 insertions, 24 deletions
diff --git a/src/insexpand.c b/src/insexpand.c
index 66507f0436..8d76c686f5 100644
--- a/src/insexpand.c
+++ b/src/insexpand.c
@@ -121,7 +121,6 @@ struct compl_S
static char e_hitend[] = N_("Hit end of paragraph");
# ifdef FEAT_COMPL_FUNC
-static char e_complwin[] = N_("E839: Completion function changed window");
static char e_compldel[] = N_("E840: Completion function deleted text");
# endif
@@ -2199,8 +2198,6 @@ expand_by_function(
typval_T args[3];
char_u *funcname;
pos_T pos;
- win_T *curwin_save;
- buf_T *curbuf_save;
typval_T rettv;
int save_State = State;
@@ -2216,8 +2213,6 @@ expand_by_function(
args[2].v_type = VAR_UNKNOWN;
pos = curwin->w_cursor;
- curwin_save = curwin;
- curbuf_save = curbuf;
// Lock the text to avoid weird things from happening. Also disallow
// switching to another window, it should not be needed and may end up in
// Insert mode in another buffer.
@@ -2246,11 +2241,6 @@ expand_by_function(
}
--textwinlock;
- if (curwin_save != curwin || curbuf_save != curbuf)
- {
- emsg(_(e_complwin));
- goto theend;
- }
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
if (!EQUAL_POS(curwin->w_cursor, pos))
@@ -3843,8 +3833,6 @@ ins_complete(int c, int enable_pum)
int col;
char_u *funcname;
pos_T pos;
- win_T *curwin_save;
- buf_T *curbuf_save;
int save_State = State;
// Call 'completefunc' or 'omnifunc' and get pattern length as a
@@ -3866,16 +3854,11 @@ ins_complete(int c, int enable_pum)
args[1].vval.v_string = (char_u *)"";
args[2].v_type = VAR_UNKNOWN;
pos = curwin->w_cursor;
- curwin_save = curwin;
- curbuf_save = curbuf;
+ ++textwinlock;
col = call_func_retnr(funcname, 2, args);
+ --textwinlock;
State = save_State;
- if (curwin_save != curwin || curbuf_save != curbuf)
- {
- emsg(_(e_complwin));
- return FAIL;
- }
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
if (!EQUAL_POS(curwin->w_cursor, pos))
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 489c1d9d94..613e9520d9 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -548,7 +548,7 @@ func Test_completefunc_error()
endfunc
set completefunc=CompleteFunc
call setline(1, ['', 'abcd', ''])
- call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E840:')
+ call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E578:')
" delete text when called for the second time
func CompleteFunc2(findstart, base)
diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim
index 2d0625bc09..c8f8820af4 100644
--- a/src/testdir/test_popup.vim
+++ b/src/testdir/test_popup.vim
@@ -367,11 +367,9 @@ func Test_completefunc_opens_new_window_two()
setlocal completefunc=DummyCompleteTwo
call setline(1, 'two')
/^two
- call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E839:')
- call assert_notequal(winid, win_getid())
- q!
+ call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
call assert_equal(winid, win_getid())
- call assert_equal('two', getline(1))
+ call assert_equal('twodef', getline(1))
q!
endfunc
diff --git a/src/version.c b/src/version.c
index ed17716a7e..98f01dd790 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2427,
+/**/
2426,
/**/
2425,