mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix(api): open_win fire Buf* events when !enter && !noautocmd if entered early
Problem: if switch_win{_noblock} fails to restore the old curwin after WinNew (e.g: it was closed), wp will become the new curwin, but win_set_buf enter events would still be blocked if !enter && !noautocmd. Solution: fire them, as we've actually entered the new window. Note: there's a problem of switch_win{_noblock} failing to restore the old curwin, leaving us in wp without triggering WinEnter/WinLeave, but this affects all callers of switch_win{_noblock} anyways. (It's also not clear how WinLeave can be called if the old curwin was closed already).
This commit is contained in:
parent
a873f33993
commit
e55a502ed4
@ -294,7 +294,7 @@ Window nvim_open_win(Buffer buffer, Boolean enter, Dict(win_config) *config, Err
|
|||||||
tp = win_find_tabpage(wp);
|
tp = win_find_tabpage(wp);
|
||||||
}
|
}
|
||||||
if (tp && buf != wp->w_buffer) {
|
if (tp && buf != wp->w_buffer) {
|
||||||
const bool noautocmd = !enter || fconfig.noautocmd;
|
const bool noautocmd = curwin != wp || fconfig.noautocmd;
|
||||||
win_set_buf(wp, buf, noautocmd, err);
|
win_set_buf(wp, buf, noautocmd, err);
|
||||||
if (!noautocmd) {
|
if (!noautocmd) {
|
||||||
tp = win_find_tabpage(wp);
|
tp = win_find_tabpage(wp);
|
||||||
|
@ -1571,6 +1571,16 @@ describe('API/win', function()
|
|||||||
)
|
)
|
||||||
eq(false, eval('fired'))
|
eq(false, eval('fired'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('fires Buf* autocommands when `!enter` if window is entered via autocommands', function()
|
||||||
|
exec([[
|
||||||
|
autocmd WinNew * ++once only!
|
||||||
|
let fired = v:false
|
||||||
|
autocmd BufEnter * ++once let fired = v:true
|
||||||
|
]])
|
||||||
|
api.nvim_open_win(api.nvim_create_buf(true, true), false, { split = 'left' })
|
||||||
|
eq(true, eval('fired'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('set_config', function()
|
describe('set_config', function()
|
||||||
|
Loading…
Reference in New Issue
Block a user