neovim/test/functional/api
Sean Dewar a70eae57bd
fix(api): make open_win block only enter/leave events if !enter && !noautocmd
Problem: nvim_open_win blocking all win_set_buf autocommands when !enter &&
!noautocmd is too aggressive.

Solution: temporarily block WinEnter/Leave and BufEnter/Leave events when
setting the buffer. Delegate the firing of BufWinEnter back to win_set_buf,
which also has the advantage of keeping the timing consistent (e.g: before the
epilogue in enter_buffer, which also handles restoring the cursor position if
autocommands didn't change it, among other things). Reword the documentation for
noautocmd a bit.

I pondered modifying do_buffer and callees to allow for BufEnter/Leave being
conditionally disabled, but it seems too invasive (and potentially error-prone,
especially if new code paths to BufEnter/Leave are added in the future).

Unfortunately, doing this has the drawback of blocking ALL such events for the
duration, which also means blocking unrelated such events; like if window
switching occurs in a ++nested autocmd fired by win_set_buf. If this turns out
to be a problem in practice, a different solution specialized for nvim_open_win
could be considered. :-)
2024-03-08 23:24:04 +00:00
..
autocmd_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
buffer_spec.lua test: use integers for API Buffer/Window/Tabpage EXT types 2024-01-16 19:11:49 +00:00
buffer_updates_spec.lua refactor(tests): get channel id via nvim_get_chan_info #27441 2024-02-12 05:50:39 -08:00
command_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
extmark_spec.lua feat(extmarks): subpriorities (relative to declaration order) (#27131) 2024-01-28 21:13:58 -06:00
highlight_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
keymap_spec.lua feat(api): support getting abbreviations (#26868) 2024-01-20 08:08:44 +08:00
menu_spec.lua refactor: format test/* 2024-01-03 02:09:29 +01:00
proc_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
rpc_fixture.lua refactor: format test/* 2024-01-03 02:09:29 +01:00
server_notifications_spec.lua refactor(tests): get channel id via nvim_get_chan_info #27441 2024-02-12 05:50:39 -08:00
server_requests_spec.lua refactor(tests): get channel id via nvim_get_chan_info #27441 2024-02-12 05:50:39 -08:00
tabpage_spec.lua feat(api): add nvim_tabpage_set_win (#27222) 2024-01-29 15:18:33 +08:00
ui_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
version_spec.lua test: rename (meths, funcs) -> (api, fn) 2024-01-12 18:59:14 +00:00
vim_spec.lua test: more tests for nvim_eval_statusline "fillchar" (#27502) 2024-02-17 08:45:35 +08:00
window_spec.lua fix(api): make open_win block only enter/leave events if !enter && !noautocmd 2024-03-08 23:24:04 +00:00