mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 05:28:33 +00:00
fix(api,lsp): call on_detach before wiping out the buffer #35355
Problem: Buffer-updates on_detach callback is invoked before buf_freeall(), which deletes autocmds of the buffer (via apply_autocmds(EVENT_BUFWIPEOUT, ...)). Due to this, buffer-local autocmds executed in on_detach (e.g., LspDetach) are not actually invoked. Solution: Call buf_updates_unload() before buf_freeall().
This commit is contained in:
@@ -656,6 +656,10 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i
|
||||
|
||||
buf->b_nwindows = nwindows;
|
||||
|
||||
// Disable buffer-updates for the current buffer.
|
||||
// No need to check `unload_buf`: in that case the function returned above.
|
||||
buf_updates_unload(buf, false);
|
||||
|
||||
buf_freeall(buf, ((del_buf ? BFA_DEL : 0)
|
||||
+ (wipe_buf ? BFA_WIPE : 0)
|
||||
+ (ignore_abort ? BFA_IGNORE_ABORT : 0)));
|
||||
@@ -678,10 +682,6 @@ bool close_buffer(win_T *win, buf_T *buf, int action, bool abort_if_last, bool i
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disable buffer-updates for the current buffer.
|
||||
// No need to check `unload_buf`: in that case the function returned above.
|
||||
buf_updates_unload(buf, false);
|
||||
|
||||
if (win != NULL // Avoid bogus clang warning.
|
||||
&& win_valid_any_tab(win)
|
||||
&& win->w_buffer == buf) {
|
||||
|
Reference in New Issue
Block a user