skywind3000/asyncrun.vim

The `hidden` option cannot work with the `close` option

Closed this issue · 2 comments

Vim version: 8.2.4700
asyncrun.vim version: aa8a99e

The terminal buffer will be deleted rather than hidden when using the following option combination :

{'mode': 'term', 'hidden': 1, 'pos': 'tab', 'close': 1}

IMHO, this bug is due to s:terminal_exit() always bdelete the buffer rather than close the window:

if info.close != 0
let bid = info.bid
if bid >= 0
if getbufvar(bid, '&bt', '') == 'terminal'
silent! exec "bd! " . bid
endif
endif
endif

It is not possible to call close inside s:terminal_exit(), because there might be none or many windows binding to a certain terminal buffer.

For example , while terminal job is still running, user may manually close the terminal window, or split the terminal window into two windows. or change the current tabpage/window.

The most straight forward way to close them all is deleting the buffer directly.

Other wise, you need to iterate every window in each tabpage to see if they are related to your terminal buffer id.

This may require current tabpage/window switching, and user may lost their input focus and break the input combo.

For hidden feature , you can simply use it without -mode=term. since you don't care about the output

Thank you for the prompt reply 😀
Indeed, I can't find a way to close the terminal window without affecting the user experience.