git-messenger.vim icon indicating copy to clipboard operation
git-messenger.vim copied to clipboard

Question about autocmd on float window

Open xaljer opened this issue 5 years ago • 5 comments

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?

  1. Is this the vim/nvim behavior which plugins can not do something to change it ?
  2. Does git-messenger depends on this autocmd? Could git-messenger do something to make no BufEnter on popup window show or BufEnter again 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~

xaljer avatar Sep 06 '20 03:09 xaljer

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 BufEnter configuration 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:

  1. You run :GitMessenger command
  2. git-messenger.vim executes Git commands like git blame
  3. Opens popup window with float window
  4. Move the cursor into the popup window
  5. Set BufEnter autocmd 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

rhysd avatar Sep 21 '20 08:09 rhysd

I believe lewis6991/gitsigns.nvim#484 is an example of this issue.

ambroisie avatar Mar 04 '22 14:03 ambroisie

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.

Alex-duzhichao avatar Mar 23 '22 03:03 Alex-duzhichao

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.

Alex-duzhichao avatar Mar 23 '22 15:03 Alex-duzhichao