Problem: When 'buftype' is "nofile" there is no overwrite check.
Solution: Also check for existing file when 'buftype' is set.
(closes #5807)
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)
&& 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)
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
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 403,
/**/
402,
/**/