scrollbar.nvim icon indicating copy to clipboard operation
scrollbar.nvim copied to clipboard

When scrollbar visible cannot close window

Open khalidchawtany opened this issue 4 years ago • 7 comments

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

khalidchawtany avatar Sep 22 '20 06:09 khalidchawtany

how to reproduce?

Xuyuanp avatar Sep 22 '20 07:09 Xuyuanp

Maybe related to this https://github.com/neovim/neovim/pull/11938

Xuyuanp avatar Sep 23 '20 14:09 Xuyuanp

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()

jeromedalbert avatar Sep 27 '20 20:09 jeromedalbert

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 https://github.com/neovim/neovim/pull/11938

Xuyuanp avatar Sep 28 '20 08:09 Xuyuanp

@Xuyuanp use QuitPro autocmd to clear scrollbar, checkout https://github.com/SpaceVim/SpaceVim/pull/3855, now it works for me.

wsdjeg avatar Sep 30 '20 16:09 wsdjeg

@wsdjeg thanks

Xuyuanp avatar Oct 01 '20 06:10 Xuyuanp

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

J053Fabi0 avatar Sep 28 '21 16:09 J053Fabi0