]> granicus.if.org Git - vim/commitdiff
patch 8.1.2187: error for bad regexp even though regexp is not used v8.1.2187
authorBram Moolenaar <Bram@vim.org>
Sat, 19 Oct 2019 19:01:05 +0000 (21:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 19 Oct 2019 19:01:05 +0000 (21:01 +0200)
Problem:    Error for bad regexp even though regexp is not used when writing
            a file. (Arseny Nasokin)
Solution:   Ignore regexp errors. (closes #5059)

src/cmdexpand.c
src/ex_docmd.c
src/testdir/test_writefile.vim
src/version.c

index b3f18c6dec13a7fd3770962a11384270d1ddc4a2..7381b0e9b7c838aba42a3dd4605391eebd7a400b 100644 (file)
@@ -1976,6 +1976,8 @@ ExpandFromContext(
        flags |= EW_KEEPALL;
     if (options & WILD_SILENT)
        flags |= EW_SILENT;
+    if (options & WILD_NOERROR)
+       flags |= EW_NOERROR;
     if (options & WILD_ALLLINKS)
        flags |= EW_ALLLINKS;
 
index 4dd7ba23d8134c8a9d208f29bfc87c2a93802287..1d0476946d9b7c31fe557277936c2aa131403687 100644 (file)
@@ -4211,7 +4211,8 @@ expand_filename(
                else /* n == 2 */
                {
                    expand_T    xpc;
-                   int         options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH;
+                   int         options = WILD_LIST_NOTFOUND
+                                              | WILD_NOERROR | WILD_ADD_SLASH;
 
                    ExpandInit(&xpc);
                    xpc.xp_context = EXPAND_FILES;
index 4b0a6d6c738f748e4d8c0fe77cf14833fcfbb34c..8eb2e7809f7cfc7c57a28189b83028be332dbc7d 100644 (file)
@@ -1,4 +1,4 @@
-" Tests for the writefile() function.
+" Tests for the writefile() function and some :write commands.
 
 func Test_writefile()
   let f = tempname()
@@ -16,6 +16,11 @@ func Test_writefile()
   call delete(f)
 endfunc
 
+func Test_writefile_ignore_regexp_error()
+  write Xt[z-a]est.txt
+  call delete('Xt[z-a]est.txt')
+endfunc
+
 func Test_writefile_fails_gently()
   call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:')
   call assert_false(filereadable("Xfile"))
index 65979b2535dede9330288d1e15f71cc7599e6212..c55af5ab5c6008b33e83ce7552cdb60097df45e2 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2187,
 /**/
     2186,
 /**/