Skip to content

Commit

Permalink
Document Issue #10.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstein64 committed Dec 29, 2020
1 parent 6a68983 commit 64804ee
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
16 changes: 16 additions & 0 deletions doc/scrollview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,21 @@ following example.
< This won't resolve the issue in all cases (e.g., when using `:close` or
`:wincmd`).

* Deleting a buffer with |:bdelete|, when it's the only visible buffer and there
are multiple buffers on the buffer list, results in the following error (with
duplicate lines, as shown): >
E444: Cannot close last window
E444: Cannot close last window
< The buffer may not be deleted from the buffer list. Neovim Issue #13628 is
the corresponding issue, opened December 28, 2020.
- Workaround 1: Use |:only| or `<ctrl-w>o`, which has the side-effect of closing
all floating windows (including scrollbars). A subsequent |:bdelete| command
works without error.
- Workaround 2: Create a `Bdelete` command that avoids the issue. >
command Bdelete
\ silent! ScrollViewDisable
\ | bdelete
\ | silent! ScrollViewEnable
============================================================================
vim:tw=78:ts=4:ft=help:norl:
21 changes: 14 additions & 7 deletions plugin/scrollview.vim
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ let g:scrollview_base = get(g:, 'scrollview_base', 'right')
" *************************************************

if !exists(':ScrollViewRefresh')
command ScrollViewRefresh :call s:ScrollViewRefresh()
command -bar ScrollViewRefresh :call s:ScrollViewRefresh()
endif

if !exists(':ScrollViewEnable')
command ScrollViewEnable :call s:ScrollViewEnable()
command -bar ScrollViewEnable :call s:ScrollViewEnable()
endif

if !exists(':ScrollViewDisable')
command ScrollViewDisable :call s:ScrollViewDisable()
command -bar ScrollViewDisable :call s:ScrollViewDisable()
endif

" *************************************************
Expand All @@ -77,14 +77,16 @@ function! s:ScrollViewEnable() abort
" The following handles scrolling events, which could arise from various
" actions, including resizing windows, movements (e.g., j, k), or
" scrolling (e.g., <ctrl-e>, zz). Refreshing is asynchronous so that
" 'botline' is correctly calculcated where applicable, and so that mouse
" 'botline' is correctly calculated where applicable, and so that mouse
" wheel scrolls are more responsive (since redundant refreshes are
" dropped).
autocmd WinScrolled * :call scrollview#RefreshBarsAsync()
" The following handles the case where text is pasted. TextChangedI is not
" necessary since WinScrolled will be triggered if there is corresponding
" scrolling.
autocmd TextChanged * :call scrollview#RefreshBars()
" scrolling. Refreshing is asynchronous so that 'botline' is correctly
" calculated where applicable (e.g., dG command, to delete from current
" line until the end of the document).
autocmd TextChanged * :call scrollview#RefreshBarsAsync()
" The following handles when :e is used to load a file. The asynchronous
" version is used to handle the case where :e is used to reload an
" existing file, that is already scrolled. This avoids a scenario where
Expand All @@ -108,7 +110,12 @@ function! s:ScrollViewEnable() abort
autocmd QuitPre * :call scrollview#RemoveBars()
autocmd VimResized * :call scrollview#RefreshBars()
augroup END
call scrollview#RefreshBars()
" The initial refresh is asynchronous, since :ScrollViewEnable can be used
" in a context where Neovim is in an intermediate state. For example, for
" ':bdelete | ScrollViewEnable', with synchronous processing, the 'topline'
" and 'botline' in getwininfo's results correspond to the existing buffer
" that :bdelete was called on.
call scrollview#RefreshBarsAsync()
endfunction

function! s:ScrollViewDisable() abort
Expand Down

0 comments on commit 64804ee

Please sign in to comment.