-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BufWinEnter not called for floating window buffer #27121
Comments
Related #15300 |
This comment was marked as resolved.
This comment was marked as resolved.
Hmm, the current behavior is inconsistent with |
I would expect
That to me sounds like it should fire even if the window doesn't have focus. Another way to put it: I would expect there to be an invariant that if a buffer is displayed in a window, |
there use neovim/src/nvim/api/win_config.c Lines 202 to 203 in 1233ac4
|
@justinmk Not sure if related, but on the contrary, if we create the hover window, and |
Problem: BufWinEnter is not fired when not entering a new window, even when the buffer is now no longer hidden and buffer-related autocommands are not blocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also add some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
…r && !noautocmd` Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like `:{s}buffer`. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also, bail early from `win_set_buf` if setting the temp curwin fails; this shouldn't be possible, as the callers check that `wp` is valid, but in case that's ever not true, `win_set_buf` will no longer continue setting a buffer for the wrong window. Note that `pum_create_float_preview` also uses `win_set_buf`, but from a glance, doesn't look like it properly checks for autocmds screwing things up (`win_enter`, `nvim_create_buf`...). I haven't addressed that here. Also adds some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
…r && !noautocmd` Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like `:{s}buffer`. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also, bail early from `win_set_buf` if setting the temp curwin fails; this shouldn't be possible, as the callers check that `wp` is valid, but in case that's ever not true, `win_set_buf` will no longer continue setting a buffer for the wrong window. Note that `pum_create_float_preview` also uses `win_set_buf`, but from a glance, doesn't look like it properly checks for autocmds screwing things up (`win_enter`, `nvim_create_buf`...). I haven't addressed that here. Also adds some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
…r && !noautocmd` Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like `:{s}buffer`. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also, bail early from `win_set_buf` if setting the temp curwin fails; this shouldn't be possible, as the callers check that `wp` is valid, but in case that's ever not true, `win_set_buf` will no longer continue setting a buffer for the wrong window. Note that `pum_create_float_preview` also uses `win_set_buf`, but from a glance, doesn't look like it properly checks for autocmds screwing things up (`win_enter`, `nvim_create_buf`...). I haven't addressed that here. Also adds some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
…r && !noautocmd` Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like `:{s}buffer`. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also, bail early from `win_set_buf` if setting the temp curwin fails; this shouldn't be possible, as the callers check that `wp` is valid, but in case that's ever not true, `win_set_buf` will no longer continue setting a buffer for the wrong window. Note that `pum_create_float_preview` also uses `win_set_buf`, but from a glance, doesn't look like it properly checks for autocmds screwing things up (`win_enter`, `nvim_create_buf`...). I haven't addressed that here. Also adds some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
…r && !noautocmd` Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (`!noautocmd`). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like `:{s}buffer`. Be wary of autocommands screwing us over! For example, it's possible for `nvim_win_set_config` to be used in an autocommand to move a window to a different tabpage (in contrast, things like `wincmd T` actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this...). Also, bail early from `win_set_buf` if setting the temp curwin fails; this shouldn't be possible, as the callers check that `wp` is valid, but in case that's ever not true, `win_set_buf` will no longer continue setting a buffer for the wrong window. Note that `pum_create_float_preview` also uses `win_set_buf`, but from a glance, doesn't look like it properly checks for autocmds screwing things up (`win_enter`, `nvim_create_buf`...). I haven't addressed that here. Also adds some test coverage for `nvim_open_win` autocommands. Closes neovim#27121.
… && !noautocmd Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (!noautocmd). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like :{s}buffer. Be wary of autocommands! For example, it's possible for nvim_win_set_config to be used in an autocommand to move a window to a different tabpage (in contrast, things like wincmd T actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this... I'd be especially cautious of logic that restores curwin and curtab without checking if curwin is still valid in curtab, if any such logic exists). Also, bail early from win_set_buf if setting the temp curwin fails; this shouldn't be possible, as the callers check that wp is valid, but in case that's not true, win_set_buf will no longer continue setting a buffer for the wrong window. Note that pum_create_float_preview also uses win_set_buf, but from a glance, doesn't look like it properly checks for autocmds screwing things up (win_enter, nvim_create_buf...). I haven't addressed that here. Also adds some test coverage for nvim_open_win autocommands. Closes neovim#27121.
… && !noautocmd Problem: BufWinEnter is not fired when not entering a new window, even when a different buffer is specified and buffer-related autocommands are unblocked (!noautocmd). Solution: fire it in the context of the new window and buffer. Do not do it if the buffer is unchanged, like :{s}buffer. Be wary of autocommands! For example, it's possible for nvim_win_set_config to be used in an autocommand to move a window to a different tabpage (in contrast, things like wincmd T actually create a *new* window, so it may not have been possible before, meaning other parts of Nvim could assume windows can't do this... I'd be especially cautious of logic that restores curwin and curtab without checking if curwin is still valid in curtab, if any such logic exists). Also, bail early from win_set_buf if setting the temp curwin fails; this shouldn't be possible, as the callers check that wp is valid, but in case that's not true, win_set_buf will no longer continue setting a buffer for the wrong window. Note that pum_create_float_preview also uses win_set_buf, but from a glance, doesn't look like it properly checks for autocmds screwing things up (win_enter, nvim_create_buf...). I haven't addressed that here. Also adds some test coverage for nvim_open_win autocommands. Closes neovim#27121.
Problem
When opening a floating window with
nvim_open_win
andenter = false
, theBufWinEnter
autocmd is not called for the buffer.Steps to reproduce
Here is a minimal repro
Sourcing this file on nightly produces a floating window that says "Waiting...". Sourcing it in 0.9.x produces a floating window that says "BufWinEnter called". BufWinEnter is called if we pass
enter = true
innvim_open_win
. This also does not appear to occur with splits.Expected behavior
BufWinEnter should be called when the buffer is first displayed in the floating window
Neovim version (nvim -v)
v0.10.0-dev-2143+g3f188bc53
Vim (not Nvim) behaves the same?
N/A
Operating system/version
Ubuntu 22.04
Terminal name/version
kitty 0.31.0
$TERM environment variable
tmux-256color
Installation
build from source
The text was updated successfully, but these errors were encountered: