From c5981de29bceb91cec83dd67c89708b96859b56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= Date: Wed, 4 Jan 2017 22:20:19 +0100 Subject: [PATCH] Provide reasonable scroll context in VSplit mode In VSplit mode, show all entries if the minibufexpl window is big enough. If the window is not big enough, keep as few lines as possible unused/empty. --- plugin/minibufexpl.vim | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/plugin/minibufexpl.vim b/plugin/minibufexpl.vim index e2b3348..0a95b20 100644 --- a/plugin/minibufexpl.vim +++ b/plugin/minibufexpl.vim @@ -1094,10 +1094,14 @@ function! DisplayBuffers(curBufNum) " Place cursor at current buffer in MBE if !IsBufferIgnored(a:curBufNum) - if !g:miniBufExplShowBufNumbers - call search('\V['.s:bufUniqNameDict[a:curBufNum].']', 'w') + if !g:miniBufExplVSplit + if !g:miniBufExplShowBufNumbers + call search('\V['.s:bufUniqNameDict[a:curBufNum].']', 'w') + else + call search('\V['.a:curBufNum.':'.s:bufUniqNameDict[a:curBufNum].']', 'w') + endif else - call search('\V['.a:curBufNum.':'.s:bufUniqNameDict[a:curBufNum].']', 'w') + call cursor(a:curBufNum, 0) endif endif @@ -1206,6 +1210,11 @@ function! ResizeWindow() call DEBUG('ResizeWindow to '.l:newWidth.' columns',9) exec 'vertical resize '.l:newWidth endif + " if there are more than enough entries in both directions + " then center the selected line + let l:lines = winheight('%') / 2 + exec 'setlocal scrolloff='.l:lines + let saved_ead = &ead let &ead = 'hor' @@ -1257,6 +1266,11 @@ function! ShowBuffers() put! =s:miniBufExplBufList silent $ d _ + " in VSplit scroll the viewport as topmost as possible + if g:miniBufExplVSplit == 1 + call cursor(1,0) + endif + " Prevent the buffer from being modified. setlocal nomodifiable