voldikss / vim-floaterm

:computer: Terminal manager for (neo)vim
MIT License
2.46k stars 79 forks source link

Cursor stuck and gvim crashes when the terminal popup is toggled in two different tabs #390

Open char101 opened 1 year ago

char101 commented 1 year ago

Environment

GVim

If you are using vim(not neovim), fill in the following blanks

Configurations related to vim-floaterm in vimrc(i.e. g:floaterm_xxx):

map <silent> <F1> :FloatermToggle<CR>
tmap <silent> <F1> <C-w>:FloatermToggle<CR>

Describe your question, feature request, or bug.

Toggling the popup (using F1 as mapped above) in two different tabs causes the cursor in the other tab to be locked. Pressing F1 again in any of the tabs will crash gvim.

Steps to reproduce

Steps to reproduce the behavior:

  1. Open two blank tabs
  2. Press F1 in the first tab
  3. Press F1 in the second tab
  4. Cursor in the first tab will be stuck
  5. Pressing F1 in the first or second tab will crash gvim

I think if the popup is opened in a tab, then existing popup in other tab should be closed first.

sankl commented 6 months ago

Stable reproducible and very annoying. It seems BufHidden autocmd is not running for open floaterm popup when tabs are switched. Adding BufLeave to autoload/floaterm/terminal.vim L20 makes auto-hiding work and the crash is gone. Please update.

sankl commented 6 months ago

Something like this in .vimrc can be used as a workaround:

function! FloatermHide()
    if &filetype == 'floaterm'
        call floaterm#window#hide(bufnr('%'))
    endif
endfunction
autocmd! BufLeave * call FloatermHide()

It closes the popup when tabs are switched.