<C-w>o removes the scrollbar and Neovim cannot show it again
delphinus opened this issue · 3 comments
delphinus commented
When I type <C-w>o
to close all windows other than the focused one, the scrollbar disappears and Neovim shows an error with show()
.
:lua require('scrollbar').show()
E5108: Error executing lua ...epos/github.com/Xuyuanp/scrollbar.nvim/lua/scrollbar.lua:146: Invalid window id: 1021
This is because b:scrollbar_state.winnr
indicates a floating window that is already closed by <C-w>o
.
:unlet b:scrollbar_state
:lua require('scrollbar').show()
I can show the scrollbar again by codes above, but it is annoying a bit. So,
- Can the scrollbar stay still when
<C-w>o
pressed? - Can
show()
clearb:scrollbar_state
ifwinnr
indicates an invalid ID?
Xuyuanp commented
I pushed a fixed. please take a look.
delphinus commented
Thx! I found no error occurs on show()
. The scrollbar still disappears after <C-w>o
, but it shows again when CursorMoved
.
I wrote a workaround on my config.
function! s:only_and_show() abort
only
silent! lua require('scrollbar').show()
endfunction
map <C-w>o :silent call <SID>only_and_show()<CR>
With this, <C-w>o
does not remove the scrollbar (:only
still removes it).
Xuyuanp commented
Great tricks.