From 0fff44152d06e6b662ad4bef172af07a041d2f3f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sun, 29 Mar 2020 16:06:29 +0200 Subject: patch 8.2.0474: cannot use :write when using a plugin with BufWriteCmd Problem: Cannot use :write when using a plugin with BufWriteCmd. Solution: Reset BF_NOTEDITED after BufWriteCmd. (closes #5807) --- src/fileio.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/fileio.c') diff --git a/src/fileio.c b/src/fileio.c index 6e66a3e86..f05abe68c 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)) -- cgit v1.2.1