vim-patch:9.0.0509: confusing error for "saveas" command with "nofile" buffer (#20258)

Problem:    Confusing error for "saveas" command with "nofile" buffer.
Solution:   Give a clearer error message. (closes vim/vim#11171)
500a1f9972
This commit is contained in:
zeertzjq 2022-09-20 19:49:00 +08:00 committed by GitHub
parent abe2d90693
commit 054c27075b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -116,6 +116,8 @@ struct bw_info {
#endif #endif
static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name"); static char *e_auchangedbuf = N_("E812: Autocommands changed buffer or buffer name");
static char e_no_matching_autocommands_for_buftype_str_buffer[]
= N_("E676: No matching autocommands for buftype=%s buffer");
void filemess(buf_T *buf, char *name, char *s, int attr) void filemess(buf_T *buf, char *name, char *s, int attr)
{ {
@ -2366,7 +2368,7 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
no_wait_return--; no_wait_return--;
msg_scroll = msg_save; msg_scroll = msg_save;
if (nofile_err) { if (nofile_err) {
emsg(_("E676: No matching autocommands for acwrite buffer")); semsg(_(e_no_matching_autocommands_for_buftype_str_buffer), curbuf->b_p_bt);
} }
if (nofile_err if (nofile_err

View File

@ -216,6 +216,12 @@ func Test_saveas()
syntax off syntax off
%bw! %bw!
call delete('Xsaveas.pl') 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 endfunc
func Test_write_errors() func Test_write_errors()