When scrollbar visible cannot close window
khalidchawtany opened this issue · 7 comments
khalidchawtany commented
When scrollbar is visible and I type :q<cr>
sometimes I get the following error:
E5601: Cannot close window, only floating window would remain
nvim version is v0.5.0-c7ef80220
Xuyuanp commented
how to reproduce?
Xuyuanp commented
Maybe related to this neovim/neovim#11938
jeromedalbert commented
Steps to reproduce the issue
With the following config:
let g:scrollbar_right_offset = 0
let g:scrollbar_shape = {
\ 'head': ' ',
\ 'body': ' ',
\ 'tail': ' ',
\ }
let g:scrollbar_highlight = {
\ 'head': 'LineNr',
\ 'body': 'LineNr',
\ 'tail': 'LineNr',
\ }
let g:scrollbar_excluded_filetypes = ['nerdtree']
augroup configure_scrollbar
autocmd!
autocmd BufEnter,FocusGained,CursorMoved * silent! lua require('scrollbar').show()
autocmd BufLeave,FocusLost,VimResized * silent! lua require('scrollbar').clear()
augroup end
- Open nvim
- Do
:tabnew
- Do
:e $MYVIMRC
(or any long file that will show the scrollbar) - Do
:q
- Observe the following error message in the status line:
E5601: Cannot close window, only floating window would remain
Workaround / Potential solution
If I clear the scrollbar right before quitting with QuitPre
, I am able to close again:
autocmd BufLeave,FocusLost,VimResized,QuitPre * silent! lua require('scrollbar').clear()
Xuyuanp commented
Your solution is the best practice for now. Neovim can't close the window in a new tab and anchored by floating windows. I'll update the doc and readme later.
More details in this PR neovim/neovim#11938
wsdjeg commented
@Xuyuanp use QuitPro
autocmd to clear scrollbar, checkout SpaceVim/SpaceVim#3855, now it works for me.
J053Fabi0 commented
I would add TabEnter
and TabLeave
to the solution of @jeromedalbert.
augroup ScrollbarInit
autocmd!
autocmd CursorMoved,VimResized,QuitPre * silent! lua require('scrollbar').show()
autocmd WinEnter,FocusGained,TabEnter * silent! lua require('scrollbar').show()
autocmd WinLeave,FocusLost,VimResized,QuitPre,TabLeave * silent! lua require('scrollbar').clear()
augroup end