Skip to content
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

Question about autocmd on float window #65

Open
xaljer opened this issue Sep 6, 2020 · 5 comments
Open

Question about autocmd on float window #65

xaljer opened this issue Sep 6, 2020 · 5 comments

Comments

@xaljer
Copy link

xaljer commented Sep 6, 2020

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
Copy link
Owner

rhysd commented Sep 21, 2020

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.

execute 'autocmd BufEnter,WinEnter * call <SID>on_buf_enter(' . opener_bufnr . ')'

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
Copy link

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

@Alex-duzhichao
Copy link

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
Copy link

Alex-duzhichao commented Mar 23, 2022

git-messenger.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 added a commit to Alex-duzhichao/git-messenger.vim that referenced this issue Mar 23, 2022
After popup window has been created, git-messenager uses
`noautocmd wincmd p` to jump back to the current buffer, which
ignores BufEnter and BufLeave events. Some other plugins depends
on event BufEnter/BufLeave to take effect normally. So git-messenager
should use `wincmd p` to preserve events.

See issue rhysd#65 for details.
@ambroisie
Copy link

I've had this issue crop-up again recently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants