forked from aniani/vim
patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Problem: Allowing 'completefunc' to switch windows causes trouble. Solution: use "textwinlock" instead of "textlock".
This commit is contained in:
@@ -2218,9 +2218,10 @@ expand_by_function(
|
|||||||
pos = curwin->w_cursor;
|
pos = curwin->w_cursor;
|
||||||
curwin_save = curwin;
|
curwin_save = curwin;
|
||||||
curbuf_save = curbuf;
|
curbuf_save = curbuf;
|
||||||
// Lock the text to avoid weird things from happening. Do allow switching
|
// Lock the text to avoid weird things from happening. Also disallow
|
||||||
// to another window temporarily.
|
// switching to another window, it should not be needed and may end up in
|
||||||
++textlock;
|
// Insert mode in another buffer.
|
||||||
|
++textwinlock;
|
||||||
|
|
||||||
// Call a function, which returns a list or dict.
|
// Call a function, which returns a list or dict.
|
||||||
if (call_vim_function(funcname, 2, args, &rettv) == OK)
|
if (call_vim_function(funcname, 2, args, &rettv) == OK)
|
||||||
@@ -2243,7 +2244,7 @@ expand_by_function(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
--textlock;
|
--textwinlock;
|
||||||
|
|
||||||
if (curwin_save != curwin || curbuf_save != curbuf)
|
if (curwin_save != curwin || curbuf_save != curbuf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -562,31 +562,24 @@ func Test_completefunc_error()
|
|||||||
call setline(1, ['', 'abcd', ''])
|
call setline(1, ['', 'abcd', ''])
|
||||||
call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E578:')
|
call assert_fails('exe "normal 2G$a\<C-X>\<C-U>"', 'E578:')
|
||||||
|
|
||||||
set completefunc&
|
|
||||||
delfunc CompleteFunc
|
|
||||||
delfunc CompleteFunc2
|
|
||||||
close!
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_completefunc_error_not_asan()
|
|
||||||
" The following test causes an ASAN failure.
|
|
||||||
CheckNotAsan
|
|
||||||
|
|
||||||
" Jump to a different window from the complete function
|
" Jump to a different window from the complete function
|
||||||
func! CompleteFunc(findstart, base)
|
func CompleteFunc3(findstart, base)
|
||||||
if a:findstart == 1
|
if a:findstart == 1
|
||||||
return col('.') - 1
|
return col('.') - 1
|
||||||
endif
|
endif
|
||||||
wincmd p
|
wincmd p
|
||||||
return ['a', 'b']
|
return ['a', 'b']
|
||||||
endfunc
|
endfunc
|
||||||
set completefunc=CompleteFunc
|
set completefunc=CompleteFunc3
|
||||||
new
|
new
|
||||||
call assert_fails('exe "normal a\<C-X>\<C-U>"', 'E839:')
|
call assert_fails('exe "normal a\<C-X>\<C-U>"', 'E565:')
|
||||||
close!
|
close!
|
||||||
|
|
||||||
set completefunc&
|
set completefunc&
|
||||||
delfunc CompleteFunc
|
delfunc CompleteFunc
|
||||||
|
delfunc CompleteFunc2
|
||||||
|
delfunc CompleteFunc3
|
||||||
|
close!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for returning non-string values from 'completefunc'
|
" Test for returning non-string values from 'completefunc'
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ func Test_completefunc_opens_new_window_one()
|
|||||||
setlocal completefunc=DummyCompleteOne
|
setlocal completefunc=DummyCompleteOne
|
||||||
call setline(1, 'one')
|
call setline(1, 'one')
|
||||||
/^one
|
/^one
|
||||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E578:')
|
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
|
||||||
call assert_equal(winid, win_getid())
|
call assert_equal(winid, win_getid())
|
||||||
call assert_equal('onedef', getline(1))
|
call assert_equal('onedef', getline(1))
|
||||||
q!
|
q!
|
||||||
@@ -642,8 +642,8 @@ func Test_complete_func_mess()
|
|||||||
set completefunc=MessComplete
|
set completefunc=MessComplete
|
||||||
new
|
new
|
||||||
call setline(1, 'Ju')
|
call setline(1, 'Ju')
|
||||||
call feedkeys("A\<c-x>\<c-u>/\<esc>", 'tx')
|
call assert_fails('call feedkeys("A\<c-x>\<c-u>/\<esc>", "tx")', 'E578:')
|
||||||
call assert_equal('Oct/Oct', getline(1))
|
call assert_equal('Jan/', getline(1))
|
||||||
bwipe!
|
bwipe!
|
||||||
set completefunc=
|
set completefunc=
|
||||||
endfunc
|
endfunc
|
||||||
|
|||||||
@@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2426,
|
||||||
/**/
|
/**/
|
||||||
2425,
|
2425,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user