skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.84k stars 109 forks source link

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

Closed JS-Zheng closed 2 years ago

JS-Zheng commented 2 years ago

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: https://github.com/skywind3000/asyncrun.vim/blob/aa8a99e87e64276d52556f4d9d4f4a19afd37556/plugin/asyncrun.vim#L1394-L1401

skywind3000 commented 2 years ago

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

JS-Zheng commented 2 years ago

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