rhysd / git-messenger.vim

Vim and Neovim plugin to reveal the commit messages under the cursor
MIT License
1.34k stars 32 forks source link

Question about autocmd on float window #65

Open xaljer opened 4 years ago

xaljer commented 4 years ago

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~
rhysd commented 4 years ago

Would you describe followings? I could not understand what happened only from the description.

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
ambroisie commented 2 years ago

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

Alex-duzhichao commented 2 years ago

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 commented 2 years ago

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.

ambroisie commented 2 months ago

I've had this issue crop-up again recently