summaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-03-29 16:06:29 +0200
committerBram Moolenaar <Bram@vim.org>2020-03-29 16:06:29 +0200
commit0fff44152d06e6b662ad4bef172af07a041d2f3f (patch)
tree38a7ab7df1bbc37a2c6f612c99e2884f4ef02e1b /src/fileio.c
parent8601545338581c01e328cdc3a72c0b12d92c54cf (diff)
patch 8.2.0474: cannot use :write when using a plugin with BufWriteCmdv8.2.0474
Problem: Cannot use :write when using a plugin with BufWriteCmd. Solution: Reset BF_NOTEDITED after BufWriteCmd. (closes #5807)
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 6e66a3e862..f05abe68c9 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -261,11 +261,21 @@ readfile(
{
if (apply_autocmds_exarg(EVENT_BUFREADCMD, NULL, sfname,
FALSE, curbuf, eap))
+ {
+ int status = OK;
#ifdef FEAT_EVAL
- return aborting() ? FAIL : OK;
-#else
- return OK;
-#endif
+ if (aborting())
+ status = FAIL;
+#endif
+ // The BufReadCmd code usually uses ":read" to get the text and
+ // perhaps ":file" to change the buffer name. But we should
+ // consider this to work like ":edit", thus reset the
+ // BF_NOTEDITED flag. Then ":write" will work to overwrite the
+ // same file.
+ if (status == OK)
+ curbuf->b_flags &= ~BF_NOTEDITED;
+ return status;
+ }
}
else if (apply_autocmds_exarg(EVENT_FILEREADCMD, sfname, sfname,
FALSE, NULL, eap))