kassio / neoterm

Wrapper of some vim/neovim's :terminal functions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Deleting buffer at TermClose event doesn't trigger WinEnter/BufEnter events

jceb opened this issue · comments

Describe the bug
I maintain the blinds.nvim plugin that changes the background color of windows that are currently not selected. The functionality relies on WinEnter and BufEnter events fire. With Neoterm I noticed that the events aren't triggerd when I close a terminal.
The reason for this appears to be that vim doesn't fire WinEnter and BufEnter events when a buffer is deleted in the TermClose event.

For debugging purposes I disabled the TermClose auto command. This solved the issue. Furthermore, I ran an explicit :bw! on a newly created neoterm window and it still called the neoterm#destroy function through the job.on_exit handler - this handler doesn't cause the issue that TermClose does (it might also be a neovim bug). My impression is that the TermClose auto command can be deleted because the underlying functionality of cleaning up the terminal buffer is already triggered through the job.on_exit handler.

To Reproduce
Steps to reproduce the behavior:

  1. Open neovim (window 1 contains the empty buffer)
  2. Create a second window :new
  3. Opened a neoterm with :T bash in window 2
  4. Display all auto commands set verbose=9
  5. exit neoterm ''
  6. See error, no WinEnter or BufEnter auto command ist triggerd

Expected behavior
Window 1 should have the background color of the active window.

Screenshots
What's shown in the gif should happen but it doesn't happen:

Versions (please complete the following information):

  • OS: Archlinux
  • neoterm commit sha1: 511f6c6
  • Vim or Neovim
    • Neovim
    • Vim
  • Version [vim --version]
NVIM v0.4.2
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPAC
K_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.2/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

Hi there, first of all, thanks for the very detailed issue. <3

My impression is that the TermClose auto command can be deleted because the underlying functionality of cleaning up the terminal buffer is already triggered through the job.on_exit handler.

Yeah, I agree. I did a quick test and without the TermClose action the BufEnter worked and the destruction of the neoterm object seem to work properly. 🎉