]> granicus.if.org Git - vim/commitdiff
patch 8.2.0403: when 'buftype' is "nofile" there is no overwrite check v8.2.0403
authorBram Moolenaar <Bram@vim.org>
Thu, 19 Mar 2020 11:38:34 +0000 (12:38 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 19 Mar 2020 11:38:34 +0000 (12:38 +0100)
Problem:    When 'buftype' is "nofile" there is no overwrite check.
Solution:   Also check for existing file when 'buftype' is set.
            (closes #5807)

src/ex_cmds.c
src/testdir/test_options.vim
src/version.c

index f92537862f2de8c2970e4a36cba49f809664205f..ce5db88604582dcab7269ddc301a3aeed59fd6b2 100644 (file)
@@ -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)
index 3fc016122196dd236d0e3077b787dc19bbd8ac9c..fbc6dc193d23978fe5dcbac6ba820afd445585f2 100644 (file)
@@ -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
index c76d3126994a13720b032e762f8c2d19b8339bcd..83feed984a202d3fb99fa2daa524ea1b8c5818ec 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    403,
 /**/
     402,
 /**/