mirror of
https://github.com/neovim/neovim.git
synced 2025-09-16 00:08:19 +00:00
vim-patch:8.2.2427: can still switch windows for 'completefunc'
Problem: Can still switch windows for 'completefunc'.
Solution: Also disallow switching windows for other completions.
3eb6bd9c2b
Assert E565 instead of E578.
Need to assert a different string because patch 8.2.1919 hasn't been
ported yet.
This commit is contained in:
@@ -136,7 +136,6 @@ static char *ctrl_x_mode_names[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static char e_hitend[] = N_("Hit end of paragraph");
|
static char e_hitend[] = N_("Hit end of paragraph");
|
||||||
static char e_complwin[] = N_("E839: Completion function changed window");
|
|
||||||
static char e_compldel[] = N_("E840: Completion function deleted text");
|
static char e_compldel[] = N_("E840: Completion function deleted text");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3939,8 +3938,6 @@ static void expand_by_function(int type, char_u *base)
|
|||||||
dict_T *matchdict = NULL;
|
dict_T *matchdict = NULL;
|
||||||
char_u *funcname;
|
char_u *funcname;
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
win_T *curwin_save;
|
|
||||||
buf_T *curbuf_save;
|
|
||||||
typval_T rettv;
|
typval_T rettv;
|
||||||
const int save_State = State;
|
const int save_State = State;
|
||||||
|
|
||||||
@@ -3959,8 +3956,6 @@ static void expand_by_function(int type, char_u *base)
|
|||||||
args[1].vval.v_string = base != NULL ? (char *)base : "";
|
args[1].vval.v_string = base != NULL ? (char *)base : "";
|
||||||
|
|
||||||
pos = curwin->w_cursor;
|
pos = curwin->w_cursor;
|
||||||
curwin_save = curwin;
|
|
||||||
curbuf_save = curbuf;
|
|
||||||
// Lock the text to avoid weird things from happening. Also disallow
|
// 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
|
// switching to another window, it should not be needed and may end up in
|
||||||
// Insert mode in another buffer.
|
// Insert mode in another buffer.
|
||||||
@@ -3985,10 +3980,6 @@ static void expand_by_function(int type, char_u *base)
|
|||||||
}
|
}
|
||||||
textlock--;
|
textlock--;
|
||||||
|
|
||||||
if (curwin_save != curwin || curbuf_save != curbuf) {
|
|
||||||
emsg(_(e_complwin));
|
|
||||||
goto theend;
|
|
||||||
}
|
|
||||||
curwin->w_cursor = pos; // restore the cursor position
|
curwin->w_cursor = pos; // restore the cursor position
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
if (!equalpos(curwin->w_cursor, pos)) {
|
if (!equalpos(curwin->w_cursor, pos)) {
|
||||||
@@ -5226,8 +5217,6 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
// set to 1 to obtain the length of text to use for completion.
|
// set to 1 to obtain the length of text to use for completion.
|
||||||
char_u *funcname;
|
char_u *funcname;
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
win_T *curwin_save;
|
|
||||||
buf_T *curbuf_save;
|
|
||||||
const int save_State = State;
|
const int save_State = State;
|
||||||
|
|
||||||
// Call 'completefunc' or 'omnifunc' and get pattern length as a string
|
// Call 'completefunc' or 'omnifunc' and get pattern length as a string
|
||||||
@@ -5248,15 +5237,11 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
args[1].vval.v_string = "";
|
args[1].vval.v_string = "";
|
||||||
|
|
||||||
pos = curwin->w_cursor;
|
pos = curwin->w_cursor;
|
||||||
curwin_save = curwin;
|
textlock++;
|
||||||
curbuf_save = curbuf;
|
|
||||||
colnr_T col = (colnr_T)call_func_retnr((char *)funcname, 2, args);
|
colnr_T col = (colnr_T)call_func_retnr((char *)funcname, 2, args);
|
||||||
|
textlock--;
|
||||||
|
|
||||||
State = save_State;
|
State = save_State;
|
||||||
if (curwin_save != curwin || curbuf_save != curbuf) {
|
|
||||||
emsg(_(e_complwin));
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
curwin->w_cursor = pos; // restore the cursor position
|
curwin->w_cursor = pos; // restore the cursor position
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
if (!equalpos(curwin->w_cursor, pos)) {
|
if (!equalpos(curwin->w_cursor, pos)) {
|
||||||
|
@@ -614,7 +614,7 @@ func Test_completefunc_error()
|
|||||||
endfunc
|
endfunc
|
||||||
set completefunc=CompleteFunc
|
set completefunc=CompleteFunc
|
||||||
call setline(1, ['', 'abcd', ''])
|
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>"', 'E565:')
|
||||||
|
|
||||||
" delete text when called for the second time
|
" delete text when called for the second time
|
||||||
func CompleteFunc2(findstart, base)
|
func CompleteFunc2(findstart, base)
|
||||||
|
@@ -382,11 +382,11 @@ func Test_completefunc_opens_new_window_two()
|
|||||||
setlocal completefunc=DummyCompleteTwo
|
setlocal completefunc=DummyCompleteTwo
|
||||||
call setline(1, 'two')
|
call setline(1, 'two')
|
||||||
/^two
|
/^two
|
||||||
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E764:')
|
call assert_fails('call feedkeys("A\<C-X>\<C-U>\<C-N>\<Esc>", "x")', 'E565:')
|
||||||
call assert_notequal(winid, win_getid())
|
|
||||||
q!
|
|
||||||
call assert_equal(winid, win_getid())
|
call assert_equal(winid, win_getid())
|
||||||
call assert_equal('two', getline(1))
|
" v8.2.1919 hasn't been ported yet
|
||||||
|
" call assert_equal('twodef', getline(1))
|
||||||
|
call assert_equal('twoDEF', getline(1))
|
||||||
q!
|
q!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user