]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.5029: "textlock" is always zero v8.2.5029
authorzeertzjq <zeertzjq@outlook.com>
Fri, 27 May 2022 16:26:55 +0000 (17:26 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 May 2022 16:26:55 +0000 (17:26 +0100)
Problem:    "textlock" is always zero.
Solution:   Remove "textlock" and rename "textwinlock" to "textlock".
            (closes #10489)

22 files changed:
runtime/doc/insert.txt
runtime/doc/tags
src/beval.c
src/change.c
src/edit.c
src/errors.h
src/eval.c
src/ex_cmds.c
src/ex_getln.c
src/globals.h
src/indent.c
src/insexpand.c
src/map.c
src/proto/ex_getln.pro
src/register.c
src/testdir/test_edit.vim
src/testdir/test_ins_complete.vim
src/testdir/test_popup.vim
src/testdir/test_quickfix.vim
src/undo.c
src/version.c
src/window.c

index d8bddce65010d45abcd85409b884251d67a8e88a..8c35798391a295f32d7d24a95df9b5371da60a7f 100644 (file)
@@ -671,7 +671,7 @@ Note: The keys that are valid in CTRL-X mode are not mapped.  This allows for
 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.
index b8fb35988d18e06db7018a007f40699a815e64d6..c53ae5e6d525122e8cf00966881397757b603162 100644 (file)
@@ -4749,7 +4749,6 @@ E574      starting.txt    /*E574*
 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*
index a9d10a202e19a28ce3f4c46c215e5111195f7942..4b89af36672451c99fa77941450b7484e2bea06d 100644 (file)
@@ -284,7 +284,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
            curbuf = save_curbuf;
            if (use_sandbox)
                ++sandbox;
-           ++textwinlock;
+           ++textlock;
 
            if (bexpr == p_bexpr)
            {
@@ -311,7 +311,7 @@ general_beval_cb(BalloonEval *beval, int state UNUSED)
 
            if (use_sandbox)
                --sandbox;
-           --textwinlock;
+           --textlock;
            current_sctx = save_sctx;
 
            set_vim_var_string(VV_BEVAL_TEXT, NULL, -1);
index b653dcc1b678f8b682291fa96259404172849075..a9927e0fdef33c2ccf6eda1b46a49beb677bf6fc 100644 (file)
@@ -324,7 +324,7 @@ f_listener_remove(typval_T *argvars, typval_T *rettv)
            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;
@@ -401,7 +401,7 @@ invoke_listeners(buf_T *buf)
 
     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)
     {
@@ -421,7 +421,7 @@ invoke_listeners(buf_T *buf)
            prev = lnr;
     }
 
-    --textwinlock;
+    --textlock;
     list_unref(buf->b_recorded_changes);
     buf->b_recorded_changes = NULL;
 
index 939aeb9d6646f10a7837c8930099d84089a49557..443e023d5c719564bbc33b0ae8bcd33550a98579 100644 (file)
@@ -168,8 +168,7 @@ edit(
     // 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;
@@ -5342,7 +5341,7 @@ do_insert_char_pre(int c)
     }
 
     // Lock the text to avoid weird things from happening.
-    ++textwinlock;
+    ++textlock;
     set_vim_var_string(VV_CHAR, buf, -1);  // set v:char
 
     res = NULL;
@@ -5356,7 +5355,7 @@ do_insert_char_pre(int c)
     }
 
     set_vim_var_string(VV_CHAR, NULL, -1);  // clear v:char
-    --textwinlock;
+    --textlock;
 
     // Restore the State, it may have been changed.
     State = save_State;
index c819729eb4e2f56ea4c1efa6d6ecb4dcdbcc25f5..4e02986a77891ea54ec80fd5a60fa805cfc3009b 100644 (file)
@@ -1458,8 +1458,7 @@ EXTERN char e_nonr_missing_gt[]
 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"));
index 1aa0eaec75d1dfe2c967662a6dd99f3ac77ed4ba..2c70c3be10e35776f706b1d59c84f4c67d0340f2 100644 (file)
@@ -543,7 +543,7 @@ eval_to_string(
 
 /*
  * 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 *
@@ -562,12 +562,12 @@ eval_to_string_safe(
     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;
@@ -807,7 +807,7 @@ eval_foldexpr(win_T *wp, int *cp)
     ++emsg_off;
     if (use_sandbox)
        ++sandbox;
-    ++textwinlock;
+    ++textlock;
     *cp = NUL;
     if (eval0(arg, &tv, NULL, &EVALARG_EVALUATE) == FAIL)
        retval = 0;
@@ -832,7 +832,7 @@ eval_foldexpr(win_T *wp, int *cp)
     --emsg_off;
     if (use_sandbox)
        --sandbox;
-    --textwinlock;
+    --textlock;
     clear_evalarg(&EVALARG_EVALUATE, NULL);
     current_sctx = saved_sctx;
 
index 210e21fe7a5b9fb7c340829cc5e7c7ac91b182b9..4a6073d810e007847e0eae2cd714fa0eac3b5d22 100644 (file)
@@ -4414,14 +4414,14 @@ ex_substitute(exarg_T *eap)
                subflags_save = subflags;
 
                // Disallow changing text or switching window in an expression.
-               ++textwinlock;
+               ++textlock;
 #endif
                // get length of substitution part
                sublen = vim_regsub_multi(&regmatch,
                                    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.
@@ -4524,13 +4524,13 @@ ex_substitute(exarg_T *eap)
                new_end += copy_len;
 
 #ifdef FEAT_EVAL
-               ++textwinlock;
+               ++textlock;
 #endif
                (void)vim_regsub_multi(&regmatch,
                                    sub_firstlnum - regmatch.startpos[0].lnum,
                                      sub, new_end, TRUE, magic_isset(), TRUE);
 #ifdef FEAT_EVAL
-               --textwinlock;
+               --textlock;
 #endif
                sub_nsubs++;
                did_sub = TRUE;
index 6462b00f732f91c025af3e32b75c6b684cf1f1be..9dadfbf2fabebfaebea009e9eb1abc07ad8dc7de 100644 (file)
@@ -850,12 +850,12 @@ cmdline_handle_backslash_key(int c, int *gotesc)
        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)
            {
@@ -2710,13 +2710,13 @@ check_opt_wim(void)
  * '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;
 }
 
 /*
@@ -2736,19 +2736,7 @@ get_text_locked_msg(void)
     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;
 }
 
 /*
@@ -3730,11 +3718,11 @@ cmdline_paste(
     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)
     {
index bf098fdedbff18f03327271653f926c7d02bc6a1..3861e80680f9f4cb53e3e728bc59238c33ab3698 100644 (file)
@@ -846,16 +846,11 @@ EXTERN int        secure INIT(= FALSE);
                                // 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.
index ccf4aa8687cd9c53dc81cadc44e0efdd08e11952..7598c1cf5b1f86f82cd04a29cebf4e7e34950d54 100644 (file)
@@ -1872,7 +1872,7 @@ get_expr_indent(void)
     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
@@ -1886,7 +1886,7 @@ get_expr_indent(void)
 
     if (use_sandbox)
        --sandbox;
-    --textwinlock;
+    --textlock;
     current_sctx = save_sctx;
 
     // Restore the cursor position so that 'indentexpr' doesn't need to.
index 89e0ebd81888d13b748a91adbf065ec677dadce4..20df1b0f37aef2e232218ac192aca73a3ba4b3ed 100644 (file)
@@ -1144,9 +1144,9 @@ trigger_complete_changed_event(int cur)
     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);
@@ -2643,7 +2643,7 @@ expand_by_function(int type, char_u *base)
     // 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);
@@ -2669,7 +2669,7 @@ expand_by_function(int type, char_u *base)
                break;
        }
     }
-    --textwinlock;
+    --textlock;
 
     curwin->w_cursor = pos;    // restore the cursor position
     validate_cursor();
@@ -2867,7 +2867,6 @@ set_completion(colnr_T startcol, list_T *list)
 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
@@ -2880,10 +2879,6 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
        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())
@@ -2897,7 +2892,6 @@ f_complete(typval_T *argvars, typval_T *rettv UNUSED)
        if (startcol > 0)
            set_completion(startcol - 1, argvars[1].vval.v_list);
     }
-    textlock = save_textlock;
 }
 
 /*
@@ -4508,10 +4502,10 @@ get_userdefined_compl_info(colnr_T curs_col UNUSED)
     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
index a93cb2edb39bd3c22c01667bce5b07b89a42bdac..228d073a182694f49f73b9151b0ed7df0eb32884 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -1695,7 +1695,7 @@ eval_map_expr(
 
     // 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;
@@ -1710,7 +1710,7 @@ eval_map_expr(
     // 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;
index 374b0a1770a9e4ddcee461b4c26b2e287912e876..8c8bd0ebd4cd93c66c647caec1773449e5977133 100644 (file)
@@ -3,7 +3,6 @@ void cmdline_init(void);
 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);
index d5a56ae0c604de8007d7a1c0427f43c600093e93..93860bae62431651c137053d64d119e197ed90a4 100644 (file)
@@ -1055,9 +1055,9 @@ yank_do_autocmd(oparg_T *oap, yankreg_T *reg)
     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
index f8749f8814544c89ea5cbe103ca2552a390e63a0..d56ee622ead5161b23514500f6a8797a62777f84 100644 (file)
@@ -1041,7 +1041,7 @@ func Test_edit_completefunc_delete()
   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
 
index 5ae89089d06b3fd0bb8eb0fa95958d76cd491e3d..365c646a19c652bd945ac8d85a691dd018d86cf9 100644 (file)
@@ -698,7 +698,7 @@ func Test_completefunc_error()
   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)
@@ -710,7 +710,7 @@ func Test_completefunc_error()
   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)
index 9832ccf6068863fb13b1890621563ab04dea9a80..c389f63f559c4c4549439b5fe3f714397d39e813 100644 (file)
@@ -655,7 +655,7 @@ func Test_complete_func_mess()
   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=
index 6970bdcd507fec241ecd5a4b07f2c0f5564bf2ba..182d570474ba649689008e16420a443de273cb61 100644 (file)
@@ -3474,7 +3474,7 @@ endfunc
 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
index 81cc28e8b80183b0973a8005e6c12de4498eab3e..7ebad1cef9242dd4823902b78d5cc4df4778b24f 100644 (file)
@@ -331,9 +331,9 @@ undo_allowed(void)
 
     // 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;
     }
 
index 480ff28c7ccc1e7e6cd56b3e59f0159b464d2ee4..cc9cb49b49e27f897ea9a0c688711de4f2734399 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    5029,
 /**/
     5028,
 /**/
index 984fb4631c9242938d53317d2da5c46b4f932747..fa59ade4e2ed57f166ae8abef717dd1a18977805 100644 (file)
@@ -4584,7 +4584,7 @@ win_goto(win_T *wp)
        return;
     }
 #endif
-    if (text_and_win_locked())
+    if (text_locked())
     {
        beep_flush();
        text_locked_msg();