aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-17 14:15:32 +0800
committerGitHub <noreply@github.com>2022-07-17 14:15:32 +0800
commit9e7f92e59a7fbbc0e266700db1f25278eb30cb2a (patch)
treee378e7e6d6ba2e4678d92b28c2a67f4930e5a607 /src/nvim/edit.c
parent53c398d8f44f1796c216402c953512eb57733529 (diff)
parent006334f3a7014d5d23df617ed619377464d4956f (diff)
downloadrneovim-9e7f92e59a7fbbc0e266700db1f25278eb30cb2a.tar.gz
rneovim-9e7f92e59a7fbbc0e266700db1f25278eb30cb2a.tar.bz2
rneovim-9e7f92e59a7fbbc0e266700db1f25278eb30cb2a.zip
Merge pull request #19404 from zeertzjq/vim-8.2.0670
vim-patch:8.2.{0670,0698,1294,1984,2424,2426,2427,5029}: textlock patches
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 2abe9068eb..0571e71cb5 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -136,7 +136,6 @@ static char *ctrl_x_mode_names[] = {
};
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");
/*
@@ -3939,8 +3938,6 @@ static void expand_by_function(int type, char_u *base)
dict_T *matchdict = NULL;
char_u *funcname;
pos_T pos;
- win_T *curwin_save;
- buf_T *curbuf_save;
typval_T rettv;
const int save_State = State;
@@ -3959,9 +3956,9 @@ static void expand_by_function(int type, char_u *base)
args[1].vval.v_string = base != NULL ? (char *)base : "";
pos = curwin->w_cursor;
- curwin_save = curwin;
- curbuf_save = curbuf;
- // Lock the text to avoid weird things from happening.
+ // 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.
textlock++;
// Call a function, which returns a list or dict.
@@ -3983,10 +3980,6 @@ static void expand_by_function(int type, char_u *base)
}
textlock--;
- if (curwin_save != curwin || curbuf_save != curbuf) {
- emsg(_(e_complwin));
- goto theend;
- }
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
if (!equalpos(curwin->w_cursor, pos)) {
@@ -5224,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.
char_u *funcname;
pos_T pos;
- win_T *curwin_save;
- buf_T *curbuf_save;
const int save_State = State;
// Call 'completefunc' or 'omnifunc' and get pattern length as a string
@@ -5246,15 +5237,11 @@ static int ins_complete(int c, bool enable_pum)
args[1].vval.v_string = "";
pos = curwin->w_cursor;
- curwin_save = curwin;
- curbuf_save = curbuf;
+ textlock++;
colnr_T col = (colnr_T)call_func_retnr((char *)funcname, 2, args);
+ textlock--;
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 (!equalpos(curwin->w_cursor, pos)) {