]> granicus.if.org Git - vim/commitdiff
patch 8.1.2338: using Visual mark sith :s gives E20 if not set v8.1.2338
authorBram Moolenaar <Bram@vim.org>
Sat, 23 Nov 2019 20:56:46 +0000 (21:56 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 23 Nov 2019 20:56:46 +0000 (21:56 +0100)
Problem:    Using Visual mark sith :s gives E20 if not set.
Solution:   Ignore errors when handling 'incsearch'. (closes #3837)

src/ex_getln.c
src/testdir/dumps/Test_incsearch_substitute_14.dump [new file with mode: 0644]
src/testdir/test_search.vim
src/version.c

index 7d2efcac42a2f474bce6a507fcea7fea4a596da3..0a3d9d4dafe4bb87c018bad32f83867f230cf1c0 100644 (file)
@@ -197,6 +197,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     exarg_T    ea;
     pos_T      save_cursor;
     int                use_last_pat;
+    int                retval = FALSE;
 
     *skiplen = 0;
     *patlen = ccline.cmdlen;
@@ -213,6 +214,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     if (firstc != ':')
        return FALSE;
 
+    ++emsg_off;
     vim_memset(&ea, 0, sizeof(ea));
     ea.line1 = 1;
     ea.line2 = 1;
@@ -224,13 +226,13 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
 
     cmd = skip_range(ea.cmd, NULL);
     if (vim_strchr((char_u *)"sgvl", *cmd) == NULL)
-       return FALSE;
+       goto theend;
 
     // Skip over "substitute" to find the pattern separator.
     for (p = cmd; ASCII_ISALPHA(*p); ++p)
        ;
     if (*skipwhite(p) == NUL)
-       return FALSE;
+       goto theend;
 
     if (STRNCMP(cmd, "substitute", p - cmd) == 0
            || STRNCMP(cmd, "smagic", p - cmd) == 0
@@ -248,7 +250,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
        while (ASCII_ISALPHA(*(p = skipwhite(p))))
            ++p;
        if (*p == NUL)
-           return FALSE;
+           goto theend;
     }
     else if (STRNCMP(cmd, "vimgrep", MAX(p - cmd, 3)) == 0
        || STRNCMP(cmd, "vimgrepadd", MAX(p - cmd, 8)) == 0
@@ -261,13 +263,13 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
        {
            p++;
            if (*skipwhite(p) == NUL)
-               return FALSE;
+               goto theend;
        }
        if (*cmd != 'g')
            delim_optional = TRUE;
     }
     else
-       return FALSE;
+       goto theend;
 
     p = skipwhite(p);
     delim = (delim_optional && vim_isIDc(*p)) ? ' ' : *p++;
@@ -276,7 +278,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     use_last_pat = end == p && *end == delim;
 
     if (end == p && !use_last_pat)
-       return FALSE;
+       goto theend;
 
     // Don't do 'hlsearch' highlighting if the pattern matches everything.
     if (!use_last_pat)
@@ -288,7 +290,7 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
        empty = empty_pattern(p);
        *end = c;
        if (empty)
-           return FALSE;
+           goto theend;
     }
 
     // found a non-empty pattern or //
@@ -321,7 +323,10 @@ do_incsearch_highlighting(int firstc, incsearch_state_T *is_state,
     }
 
     curwin->w_cursor = save_cursor;
-    return TRUE;
+    retval = TRUE;
+theend:
+    --emsg_off;
+    return retval;
 }
 
     static void
diff --git a/src/testdir/dumps/Test_incsearch_substitute_14.dump b/src/testdir/dumps/Test_incsearch_substitute_14.dump
new file mode 100644 (file)
index 0000000..c319856
--- /dev/null
@@ -0,0 +1,9 @@
+|a+1&#ffffff0|s+0&&|d|f|a+0&#ffff4012|s+0&#ffffff0|d|f| @61
+|~+0#4040ff13&| @68
+|~| @68
+|[+3#0000000&|N|o| |N|a|m|e|]| |[|+|]| @38|1|,|1| @11|A|l@1
+|b+0&&|s|d|f|b|s|d|f| @61
+|~+0#4040ff13&| @68
+|[+1#0000000&|N|o| |N|a|m|e|]| |[|+|]| @38|1|,|1| @11|A|l@1
+|:+0&&|'|<|,|'|>|s|/|a|/|b|/|g> @56
+@70
index 190755a2d5779349a5ae76161c784b32ea60ec21..18767130599a8f393f942ee0740104dc1db63c10 100644 (file)
@@ -983,6 +983,19 @@ func Test_incsearch_substitute_dump()
   call VerifyScreenDump(buf, 'Test_incsearch_substitute_12', {})
   call term_sendkeys(buf, "\<Esc>")
   call VerifyScreenDump(buf, 'Test_incsearch_substitute_13', {})
+  call term_sendkeys(buf, ":%bwipe!\<CR>")
+  call term_sendkeys(buf, ":only!\<CR>")
+
+  "  get :'<,'>s command in history
+  call term_sendkeys(buf, ":set cmdheight=2\<CR>")
+  call term_sendkeys(buf, "aasdfasdf\<Esc>")
+  call term_sendkeys(buf, "V:s/a/b/g\<CR>")
+  " Using '<,'> does not give E20
+  call term_sendkeys(buf, ":new\<CR>")
+  call term_sendkeys(buf, "aasdfasdf\<Esc>")
+  call term_sendkeys(buf, ":\<Up>\<Up>")
+  call VerifyScreenDump(buf, 'Test_incsearch_substitute_14', {})
+  call term_sendkeys(buf, "<Esc>")
 
   call StopVimInTerminal(buf)
   call delete('Xis_subst_script')
index 996c3c5762dadc92eba0354a7a4d97e81da36b79..67ea6afe8acfd8ac81e27b83e22c1beaf6861610 100644 (file)
@@ -737,6 +737,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2338,
 /**/
     2337,
 /**/