Question about autocmd on float window
Hi, @rhysd :
I am debugging a vim plugin using BufEnter autocmd on nvim. I found that when I call :GitMessenger, a BufEnter autocmd is triggered. But BufEnter won't be triggered again when float window disappear (git_messenger_close_on_cursor_moved is true).
My plugin depends BufEnter to do some detect. When it enter to git-messenger buffer, function is closed, and there is no condition to make me open function again when back to normal buffer.
I am not familiar with vimscript, so could you help to answer my question?
- Is this the vim/nvim behavior which plugins can not do something to change it ?
- Does git-messenger depends on this autocmd? Could git-messenger do something to make no
BufEnteron popup window show orBufEnteragain when popup window close? (Because I think it may be a more compatible behavior to have pairing autocmd.) This may not an issue of git messenger, but thanks any way~
Would you describe followings? I could not understand what happened only from the description.
- Exact steps to reproduce your problem (sequence of inputs to Vim just after Vim opens)
- Your
BufEnterconfiguration in your.vimrc
Does git-messenger depends on this autocmd?
Yes.
https://github.com/rhysd/git-messenger.vim/blob/d765028cde7ee83fffcc15815d550199c407af6c/autoload/gitmessenger.vim#L69
Actual sequence of this plugin is as follows:
- You run
:GitMessengercommand - git-messenger.vim executes Git commands like
git blame - Opens popup window with float window
- Move the cursor into the popup window
- Set
BufEnterautocmd to detect when the cursor moving outside the popup window
BTW, 'verbose' option would be useful to debug such a problem. Please see :help 'verbose'.
$ nvim -V8
I believe lewis6991/gitsigns.nvim#484 is an example of this issue.
I think this problem is caused by using noautocmd in autoload/gitmessenger/popup.vim, it ignores all events.
Lots of plugins depend on Buf* events, so I think it's better to not ignore events.
@rhysd hi, do you have any solution to fix this problem? Thanks.
https://user-images.githubusercontent.com/9667107/159734777-36e1b067-dd32-4743-bad2-09ae7c9c25d9.mp4
I use git-messenger with APZelos/blamer.nvim. After calling GitMessenger, blamer.nvim stop showing blame infomations. It's because blamer.nvim uses BufEnter/BufLeave events to decide whether to show blame info, but git-messenger use noautocmd wincmd p to switch between current buffer and popup window, which ignores BufEnter/BufLeave events.
If I replace noautocmd wincmd p to wincmd p, this problem is fixed.
@rhysd Hi buddy, do you think this fix is correct ? Thanks.