Problem: "textlock" is always zero.
Solution: Remove "textlock" and rename "textwinlock" to "textlock".
(closes #10489)
ends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.
Also, when doing completion with 'complete' mappings apply as usual.
- *E578* *E565*
+ *E565*
Note: While completion is active Insert mode can't be used recursively and
buffer text cannot be changed. Mappings that somehow invoke ":normal i.."
will generate an E565 error.
E575 starting.txt /*E575*
E576 starting.txt /*E576*
E577 starting.txt /*E577*
-E578 insert.txt /*E578*
E579 eval.txt /*E579*
E580 eval.txt /*E580*
E581 eval.txt /*E581*
curbuf = save_curbuf;
if (use_sandbox)
++sandbox;
- ++textwinlock;
+ ++textlock;
if (bexpr == p_bexpr)
{
if (use_sandbox)
--sandbox;
- --textwinlock;
+ --textlock;
current_sctx = save_sctx;
set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
next = lnr->lr_next;
if (lnr->lr_id == id)
{
- if (textwinlock > 0)
+ if (textlock > 0)
{
// in invoke_listeners(), clear ID and delete later
lnr->lr_id = 0;
argv[4].v_type = VAR_LIST;
argv[4].vval.v_list = buf->b_recorded_changes;
- ++textwinlock;
+ ++textlock;
for (lnr = buf->b_listener; lnr != NULL; lnr = lnr->lr_next)
{
prev = lnr;
}
- --textwinlock;
+ --textlock;
list_unref(buf->b_recorded_changes);
buf->b_recorded_changes = NULL;
// Don't allow changes in the buffer while editing the cmdline. The
// caller of getcmdline() may get confused.
// Don't allow recursive insert mode when busy with completion.
- if (textwinlock != 0 || textlock != 0
- || ins_compl_active() || compl_busy || pum_visible())
+ if (textlock != 0 || ins_compl_active() || compl_busy || pum_visible())
{
emsg(_(e_not_allowed_to_change_text_or_change_window));
return FALSE;
}
// Lock the text to avoid weird things from happening.
- ++textwinlock;
+ ++textlock;
set_vim_var_string(VV_CHAR, buf, -1); // set v:char
res = NULL;
}
set_vim_var_string(VV_CHAR, NULL, -1); // clear v:char
- --textwinlock;
+ --textlock;
// Restore the State, it may have been changed.
State = save_State;
EXTERN char e_illegal_register_name[]
INIT(= N_("Illegal register name"));
#endif
-EXTERN char e_not_allowed_to_change_text_here[]
- INIT(= N_("E578: Not allowed to change text here"));
+// E578 unused
#ifdef FEAT_EVAL
EXTERN char e_if_nesting_too_deep[]
INIT(= N_("E579: :if nesting too deep"));
/*
* Call eval_to_string() without using current local variables and using
- * textwinlock. When "use_sandbox" is TRUE use the sandbox.
+ * textlock. When "use_sandbox" is TRUE use the sandbox.
* Use legacy Vim script syntax.
*/
char_u *
save_funccal(&funccal_entry);
if (use_sandbox)
++sandbox;
- ++textwinlock;
+ ++textlock;
may_garbage_collect = FALSE;
retval = eval_to_string(arg, FALSE);
if (use_sandbox)
--sandbox;
- --textwinlock;
+ --textlock;
may_garbage_collect = save_garbage;
restore_funccal();
current_sctx.sc_version = save_sc_version;
++emsg_off;
if (use_sandbox)
++sandbox;
- ++textwinlock;
+ ++textlock;
*cp = NUL;
if (eval0(arg, &tv, NULL, &EVALARG_EVALUATE) == FAIL)
retval = 0;
--emsg_off;
if (use_sandbox)
--sandbox;
- --textwinlock;
+ --textlock;
clear_evalarg(&EVALARG_EVALUATE, NULL);
current_sctx = saved_sctx;
subflags_save = subflags;
// Disallow changing text or switching window in an expression.
- ++textwinlock;
+ ++textlock;
#endif
// get length of substitution part
sublen = vim_regsub_multi(®match,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, sub_firstline, FALSE, magic_isset(), TRUE);
#ifdef FEAT_EVAL
- --textwinlock;
+ --textlock;
// If getting the substitute string caused an error, don't do
// the replacement.
new_end += copy_len;
#ifdef FEAT_EVAL
- ++textwinlock;
+ ++textlock;
#endif
(void)vim_regsub_multi(®match,
sub_firstlnum - regmatch.startpos[0].lnum,
sub, new_end, TRUE, magic_isset(), TRUE);
#ifdef FEAT_EVAL
- --textwinlock;
+ --textlock;
#endif
sub_nsubs++;
did_sub = TRUE;
c = get_expr_register();
if (c == '=')
{
- // Need to save and restore ccline. And set "textwinlock"
+ // Need to save and restore ccline. And set "textlock"
// to avoid nasty things like going to another buffer when
// evaluating an expression.
- ++textwinlock;
+ ++textlock;
p = get_expr_line();
- --textwinlock;
+ --textlock;
if (p != NULL)
{
* 'balloonexpr', etc.
*/
int
-text_and_win_locked(void)
+text_locked(void)
{
#ifdef FEAT_CMDWIN
if (cmdwin_type != 0)
return TRUE;
#endif
- return textwinlock != 0;
+ return textlock != 0;
}
/*
if (cmdwin_type != 0)
return e_invalid_in_cmdline_window;
#endif
- if (textwinlock != 0)
- return e_not_allowed_to_change_text_or_change_window;
- return e_not_allowed_to_change_text_here;
-}
-
-/*
- * 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;
+ return e_not_allowed_to_change_text_or_change_window;
}
/*
regname = may_get_selection(regname);
#endif
- // Need to set "textwinlock" to avoid nasty things like going to another
+ // Need to set "textlock" to avoid nasty things like going to another
// buffer when evaluating an expression.
- ++textwinlock;
+ ++textlock;
i = get_spec_reg(regname, &arg, &allocated, TRUE);
- --textwinlock;
+ --textlock;
if (i)
{
// allowed, e.g. when sourcing .exrc or .vimrc
// in current directory
-EXTERN int textwinlock INIT(= 0);
+EXTERN int textlock INIT(= 0);
// non-zero when changing text and jumping to
// another window or editing another buffer is
// not allowed
-EXTERN int textlock INIT(= 0);
- // non-zero when changing text is not allowed,
- // jumping to another window is allowed,
- // editing another buffer is not allowed.
-
EXTERN int curbuf_lock INIT(= 0);
// non-zero when the current buffer can't be
// changed. Used for FileChangedRO.
set_vim_var_nr(VV_LNUM, curwin->w_cursor.lnum);
if (use_sandbox)
++sandbox;
- ++textwinlock;
+ ++textlock;
current_sctx = curbuf->b_p_script_ctx[BV_INDE];
// Need to make a copy, the 'indentexpr' option could be changed while
if (use_sandbox)
--sandbox;
- --textwinlock;
+ --textlock;
current_sctx = save_sctx;
// Restore the cursor position so that 'indentexpr' doesn't need to.
dict_set_items_ro(v_event);
recursive = TRUE;
- textwinlock++;
+ textlock++;
apply_autocmds(EVENT_COMPLETECHANGED, NULL, NULL, FALSE, curbuf);
- textwinlock--;
+ textlock--;
recursive = FALSE;
restore_v_event(v_event, &save_v_event);
// 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.
- ++textwinlock;
+ ++textlock;
cb = get_insert_callback(type);
retval = call_callback(cb, 0, &rettv, 2, args);
break;
}
}
- --textwinlock;
+ --textlock;
curwin->w_cursor = pos; // restore the cursor position
validate_cursor();
f_complete(typval_T *argvars, typval_T *rettv UNUSED)
{
int startcol;
- int save_textlock = textlock;
if (in_vim9script()
&& (check_for_number_arg(argvars, 0) == FAIL
return;
}
- // "textlock" is set when evaluating 'completefunc' but we can change
- // text here.
- textlock = 0;
-
// Check for undo allowed here, because if something was already inserted
// the line was already saved for undo and this check isn't done.
if (!undo_allowed())
if (startcol > 0)
set_completion(startcol - 1, argvars[1].vval.v_list);
}
- textlock = save_textlock;
}
/*
args[1].vval.v_string = (char_u *)"";
args[2].v_type = VAR_UNKNOWN;
pos = curwin->w_cursor;
- ++textwinlock;
+ ++textlock;
cb = get_insert_callback(ctrl_x_mode);
col = call_callback_retnr(cb, 2, args);
- --textwinlock;
+ --textlock;
State = save_State;
curwin->w_cursor = pos; // restore the cursor position
// Forbid changing text or using ":normal" to avoid most of the bad side
// effects. Also restore the cursor position.
- ++textwinlock;
+ ++textlock;
++ex_normal_lock;
set_vim_var_char(c); // set v:char to the typed character
save_cursor = curwin->w_cursor;
// Note: the evaluation may make "mp" invalid.
p = eval_to_string(expr, FALSE);
- --textwinlock;
+ --textlock;
--ex_normal_lock;
curwin->w_cursor = save_cursor;
msg_col = save_msg_col;
char_u *getcmdline(int firstc, long count, int indent, getline_opt_T do_concat);
char_u *getcmdline_prompt(int firstc, char_u *prompt, int attr, int xp_context, char_u *xp_arg);
int check_opt_wim(void);
-int text_and_win_locked(void);
void text_locked_msg(void);
char *get_text_locked_msg(void);
int text_locked(void);
dict_set_items_ro(v_event);
recursive = TRUE;
- textwinlock++;
+ textlock++;
apply_autocmds(EVENT_TEXTYANKPOST, NULL, NULL, FALSE, curbuf);
- textwinlock--;
+ textlock--;
recursive = FALSE;
// Empty the dictionary, v:event is still valid
set completefunc=CompleteFunc
call setline(1, ['', 'abcd', ''])
2d
- call assert_fails("normal 2G$a\<C-X>\<C-U>", 'E578:')
+ call assert_fails("normal 2G$a\<C-X>\<C-U>", 'E565:')
bwipe!
endfunc
endfunc
set completefunc=CompleteFunc
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>"', 'E565:')
" delete text when called for the second time
func CompleteFunc2(findstart, base)
endfunc
set completefunc=CompleteFunc2
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>"', 'E565:')
" Jump to a different window from the complete function
func CompleteFunc3(findstart, base)
set completefunc=MessComplete
new
call setline(1, 'Ju')
- call assert_fails('call feedkeys("A\<c-x>\<c-u>/\<esc>", "tx")', 'E578:')
+ call assert_fails('call feedkeys("A\<c-x>\<c-u>/\<esc>", "tx")', 'E565:')
call assert_equal('Jan/', getline(1))
bwipe!
set completefunc=
func Test_vimgrep_with_textlock()
new
- " Simple way to execute something with "textwinlock" set.
+ " Simple way to execute something with "textlock" set.
" Check that vimgrep without jumping can be executed.
au InsertCharPre * vimgrep /RunTheTest/j runtest.vim
normal ax
// Don't allow changes in the buffer while editing the cmdline. The
// caller of getcmdline() may get confused.
- if (textwinlock != 0 || textlock != 0)
+ if (textlock != 0)
{
- emsg(_(e_not_allowed_to_change_text_here));
+ emsg(_(e_not_allowed_to_change_text_or_change_window));
return FALSE;
}
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 5029,
/**/
5028,
/**/
return;
}
#endif
- if (text_and_win_locked())
+ if (text_locked())
{
beep_flush();
text_locked_msg();