Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide reasonable scroll context in VSplit mode #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions plugin/minibufexpl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1094,10 +1094,14 @@ function! <SID>DisplayBuffers(curBufNum)

" Place cursor at current buffer in MBE
if !<SID>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

Expand Down Expand Up @@ -1206,6 +1210,11 @@ function! <SID>ResizeWindow()
call <SID>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'
Expand Down Expand Up @@ -1257,6 +1266,11 @@ function! <SID>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

Expand Down