summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-19 12:38:34 +0100
committerBram Moolenaar <Bram@vim.org>2020-03-19 12:38:34 +0100
commita3a9c8ef697bbf6f640cde99710b6f534f29f77d (patch)
tree358717fb6832b9e8a8bb5f9710e63e994741ba21
parent30d53e2c11e670845830bdfc29bf8c1615df61a8 (diff)
patch 8.2.0403: when 'buftype' is "nofile" there is no overwrite checkv8.2.0403
Problem: When 'buftype' is "nofile" there is no overwrite check. Solution: Also check for existing file when 'buftype' is set. (closes #5807)
-rw-r--r--src/ex_cmds.c7
-rw-r--r--src/testdir/test_options.vim10
-rw-r--r--src/version.c2
3 files changed, 13 insertions, 6 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index f92537862f..ce5db88604 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -2074,8 +2074,8 @@ check_overwrite(
int other) // writing under other name
{
/*
- * write to other file or b_flags set or not writing the whole file:
- * overwriting only allowed with '!'
+ * Write to another file or b_flags set or not writing the whole file:
+ * overwriting only allowed with '!'.
*/
if ( (other
|| (buf->b_flags & BF_NOTEDITED)
@@ -2083,9 +2083,6 @@ check_overwrite(
&& vim_strchr(p_cpo, CPO_OVERNEW) == NULL)
|| (buf->b_flags & BF_READERR))
&& !p_wa
-#ifdef FEAT_QUICKFIX
- && !bt_nofilename(buf)
-#endif
&& vim_fexists(ffname))
{
if (!eap->forceit && !eap->append)
diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim
index 3fc0161221..fbc6dc193d 100644
--- a/src/testdir/test_options.vim
+++ b/src/testdir/test_options.vim
@@ -656,7 +656,15 @@ func Test_buftype()
call setline(1, ['L1'])
set buftype=nowrite
call assert_fails('write', 'E382:')
- close!
+
+ for val in ['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help', 'terminal', 'prompt', 'popup']
+ exe 'set buftype=' .. val
+ call writefile(['something'], 'XBuftype')
+ call assert_fails('write XBuftype', 'E13:', 'with buftype=' .. val)
+ endfor
+
+ call delete('XBuftype')
+ bwipe!
endfunc
" Test for the 'shellquote' option
diff --git a/src/version.c b/src/version.c
index c76d312699..83feed984a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 403,
+/**/
402,
/**/
401,