Skip to content

Commit b40c257

Browse files
committed
patch 8.1.2187: error for bad regexp even though regexp is not used
Problem: Error for bad regexp even though regexp is not used when writing a file. (Arseny Nasokin) Solution: Ignore regexp errors. (closes #5059)
1 parent 7eed964 commit b40c257

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/cmdexpand.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,8 @@ ExpandFromContext(
19761976
flags |= EW_KEEPALL;
19771977
if (options & WILD_SILENT)
19781978
flags |= EW_SILENT;
1979+
if (options & WILD_NOERROR)
1980+
flags |= EW_NOERROR;
19791981
if (options & WILD_ALLLINKS)
19801982
flags |= EW_ALLLINKS;
19811983

src/ex_docmd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4211,7 +4211,8 @@ expand_filename(
42114211
else /* n == 2 */
42124212
{
42134213
expand_T xpc;
4214-
int options = WILD_LIST_NOTFOUND|WILD_ADD_SLASH;
4214+
int options = WILD_LIST_NOTFOUND
4215+
| WILD_NOERROR | WILD_ADD_SLASH;
42154216

42164217
ExpandInit(&xpc);
42174218
xpc.xp_context = EXPAND_FILES;

src/testdir/test_writefile.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
" Tests for the writefile() function.
1+
" Tests for the writefile() function and some :write commands.
22

33
func Test_writefile()
44
let f = tempname()
@@ -16,6 +16,11 @@ func Test_writefile()
1616
call delete(f)
1717
endfunc
1818

19+
func Test_writefile_ignore_regexp_error()
20+
write Xt[z-a]est.txt
21+
call delete('Xt[z-a]est.txt')
22+
endfunc
23+
1924
func Test_writefile_fails_gently()
2025
call assert_fails('call writefile(["test"], "Xfile", [])', 'E730:')
2126
call assert_false(filereadable("Xfile"))

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2187,
744746
/**/
745747
2186,
746748
/**/

0 commit comments

Comments
 (0)