0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.0965: using one window for executing autocommands is insufficient

Problem:    Using one window for executing autocommands is insufficient.
Solution:   Use up to five windows for executing autocommands.
This commit is contained in:
Bram Moolenaar
2022-11-28 18:51:43 +00:00
parent 74a694dbe2
commit e76062c078
28 changed files with 451 additions and 260 deletions

View File

@@ -802,8 +802,15 @@ buf_write(
if (fname == buf->b_sfname)
buf_fname_s = TRUE;
// set curwin/curbuf to buf and save a few things
// Set curwin/curbuf to buf and save a few things.
aucmd_prepbuf(&aco, buf);
if (curbuf != buf)
{
// Could not find a window for "buf". Doing more might cause
// problems, better bail out.
return FAIL;
}
set_bufref(&bufref, buf);
if (append)
@@ -2592,23 +2599,26 @@ nofail:
// Apply POST autocommands.
// Careful: The autocommands may call buf_write() recursively!
// Only do this when a window was found for "buf".
aucmd_prepbuf(&aco, buf);
if (curbuf == buf)
{
if (append)
apply_autocmds_exarg(EVENT_FILEAPPENDPOST, fname, fname,
FALSE, curbuf, eap);
else if (filtering)
apply_autocmds_exarg(EVENT_FILTERWRITEPOST, NULL, fname,
FALSE, curbuf, eap);
else if (reset_changed && whole)
apply_autocmds_exarg(EVENT_BUFWRITEPOST, fname, fname,
FALSE, curbuf, eap);
else
apply_autocmds_exarg(EVENT_FILEWRITEPOST, fname, fname,
FALSE, curbuf, eap);
if (append)
apply_autocmds_exarg(EVENT_FILEAPPENDPOST, fname, fname,
FALSE, curbuf, eap);
else if (filtering)
apply_autocmds_exarg(EVENT_FILTERWRITEPOST, NULL, fname,
FALSE, curbuf, eap);
else if (reset_changed && whole)
apply_autocmds_exarg(EVENT_BUFWRITEPOST, fname, fname,
FALSE, curbuf, eap);
else
apply_autocmds_exarg(EVENT_FILEWRITEPOST, fname, fname,
FALSE, curbuf, eap);
// restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
// restore curwin/curbuf and a few other things
aucmd_restbuf(&aco);
}
#ifdef FEAT_EVAL
if (aborting()) // autocmds may abort script processing