aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-31 06:27:39 +0800
committerGitHub <noreply@github.com>2022-08-31 06:27:39 +0800
commit94a2bc594020f2bb1f41d5e2e92d05ce9c293254 (patch)
tree155cb4ad637b0a4a82f4e2528f50c60c77bdf330 /src/nvim/ex_cmds.c
parent813476bf7291dfaf9fc0ef77c9f53a07258a3801 (diff)
downloadrneovim-94a2bc594020f2bb1f41d5e2e92d05ce9c293254.tar.gz
rneovim-94a2bc594020f2bb1f41d5e2e92d05ce9c293254.tar.bz2
rneovim-94a2bc594020f2bb1f41d5e2e92d05ce9c293254.zip
vim-patch:9.0.0332: overwrite check may block BufWriteCmd (#20014)
Problem: Overwrite check may block BufWriteCmd. Solution: Do not use overwrite check when 'buftype' is "acwrite". (closes vim/vim#11011) https://github.com/vim/vim/commit/9c8f94636b3610b898ffbbd07f6b75866d16cbca
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r--src/nvim/ex_cmds.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index fc753cf65c..e672b80d69 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -1996,11 +1996,16 @@ int check_overwrite(exarg_T *eap, buf_T *buf, char *fname, char *ffname, int oth
{
// Write to another file or b_flags set or not writing the whole file:
// overwriting only allowed with '!'
+ // If "other" is false and bt_nofilename(buf) is true, this must be
+ // writing an "acwrite" buffer to the same file as its b_ffname, and
+ // buf_write() will only allow writing with BufWriteCmd autocommands,
+ // so there is no need for an overwrite check.
if ((other
- || (buf->b_flags & BF_NOTEDITED)
- || ((buf->b_flags & BF_NEW)
- && vim_strchr(p_cpo, CPO_OVERNEW) == NULL)
- || (buf->b_flags & BF_READERR))
+ || (!bt_nofilename(buf)
+ && ((buf->b_flags & BF_NOTEDITED)
+ || ((buf->b_flags & BF_NEW)
+ && vim_strchr(p_cpo, CPO_OVERNEW) == NULL)
+ || (buf->b_flags & BF_READERR))))
&& !p_wa
&& os_path_exists((char_u *)ffname)) {
if (!eap->forceit && !eap->append) {