]> granicus.if.org Git - vim/commitdiff
patch 9.0.0509: confusing error for "saveas" command with "nofile" buffer v9.0.0509
authorBram Moolenaar <Bram@vim.org>
Tue, 20 Sep 2022 10:49:10 +0000 (11:49 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 20 Sep 2022 10:49:10 +0000 (11:49 +0100)
Problem:    Confusing error for "saveas" command with "nofile" buffer.
Solution:   Give a clearer error message. (closes #11171)

src/bufwrite.c
src/errors.h
src/testdir/test_writefile.vim
src/version.c

index b283b5eb64dbd512ba34895e3d45699de228c192..3ff7fb33903f58196bf802f76263b14a177035ed 100644 (file)
@@ -888,7 +888,8 @@ buf_write(
            --no_wait_return;
            msg_scroll = msg_save;
            if (nofile_err)
-               emsg(_(e_no_matching_autocommands_for_acwrite_buffer));
+               semsg(_(e_no_matching_autocommands_for_buftype_str_buffer),
+                                                              curbuf->b_p_bt);
 
            if (nofile_err
 #ifdef FEAT_EVAL
index 5ae55b3b18de4e4a25a2827d5d5921ae9e8966f7..7f23cc8553b8e517a6cb6a71eee710368c3a58fc 100644 (file)
@@ -1715,8 +1715,8 @@ EXTERN char e_printmbcharset_cannot_be_empty_with_multi_byte_encoding[]
 EXTERN char e_no_default_font_specified_for_multi_byte_printing[]
        INIT(= N_("E675: No default font specified for multi-byte printing."));
 #endif
-EXTERN char e_no_matching_autocommands_for_acwrite_buffer[]
-       INIT(= N_("E676: No matching autocommands for acwrite buffer"));
+EXTERN char e_no_matching_autocommands_for_buftype_str_buffer[]
+       INIT(= N_("E676: No matching autocommands for buftype=%s buffer"));
 #ifdef FEAT_SYN_HL
 EXTERN char e_error_writing_temp_file[]
        INIT(= N_("E677: Error writing temp file"));
index f2b8aba57fc29496ed0f2d388baea504f7719dbe..fd6b02d93a2f2e148a68ce9b0946ade5c30e8836 100644 (file)
@@ -238,6 +238,12 @@ func Test_saveas()
   syntax off
   %bw!
   call delete('Xsaveas.pl')
+
+  " :saveas fails for "nofile" buffer
+  set buftype=nofile
+  call assert_fails('saveas Xsafile', 'E676: No matching autocommands for buftype=nofile buffer')
+
+  bwipe!
 endfunc
 
 func Test_write_errors()
index 2f545d019eeb09e0ccd5ef1f77c6f0c8157b842e..22db89017bf4428b2e54fe7057ae48eff5deef0e 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    509,
 /**/
     508,
 /**/