mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 16:08:36 +00:00
feat(aucmd_win): allow crazy things with hidden buffers (#21250)
Problem: Crash when doing crazy things with hidden buffers. Solution: Dynamically allocate the list of autocommand windows.
This commit is contained in:
@@ -2310,12 +2310,6 @@ int buf_write(buf_T *buf, char *fname, char *sfname, linenr_T start, linenr_T en
|
||||
|
||||
// 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) {
|
||||
@@ -3618,27 +3612,25 @@ 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);
|
||||
}
|
||||
|
||||
// restore curwin/curbuf and a few other things
|
||||
aucmd_restbuf(&aco);
|
||||
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);
|
||||
|
||||
if (aborting()) { // autocmds may abort script processing
|
||||
retval = false;
|
||||
}
|
||||
@@ -5013,11 +5005,6 @@ void buf_reload(buf_T *buf, int orig_mode, bool reload_options)
|
||||
|
||||
// Set curwin/curbuf for "buf" and save some things.
|
||||
aucmd_prepbuf(&aco, buf);
|
||||
if (curbuf != buf) {
|
||||
// Failed to find a window for "buf", it is dangerous to continue,
|
||||
// better bail out.
|
||||
return;
|
||||
}
|
||||
|
||||
// Unless reload_options is set, we only want to read the text from the
|
||||
// file, not reset the syntax highlighting, clear marks, diff status, etc.
|
||||
|
Reference in New Issue
Block a user