[vim] Improved compatibility with sidebar plugins (e.g. NERDtree)

This commit is contained in:
Junegunn Choi 2015-04-11 23:42:01 +09:00
parent f22b83db6c
commit 8406cedf2d

View File

@ -227,16 +227,19 @@ endfunction
function! s:split(dict) function! s:split(dict)
let directions = { let directions = {
\ 'up': ['topleft', &lines], \ 'up': ['topleft', 'resize', &lines],
\ 'down': ['botright', &lines], \ 'down': ['botright', 'resize', &lines],
\ 'left': ['vertical topleft', &columns], \ 'left': ['vertical topleft', 'vertical resize', &columns],
\ 'right': ['vertical botright', &columns] } \ 'right': ['vertical botright', 'vertical resize', &columns] }
let s:ptab = tabpagenr()
try try
for [dir, pair] in items(directions) for [dir, triple] in items(directions)
let val = get(a:dict, dir, '') let val = get(a:dict, dir, '')
if !empty(val) if !empty(val)
let [cmd, max] = pair let [cmd, resz, max] = triple
execute cmd s:calc_size(max, val).'new' let sz = s:calc_size(max, val)
execute cmd sz.'new'
execute resz sz
return return
endif endif
endfor endfor
@ -256,7 +259,11 @@ function! s:execute_term(dict, command, temps)
let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps } let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps }
function! fzf.on_exit(id, code) function! fzf.on_exit(id, code)
let tab = tabpagenr()
execute 'bd!' self.buf execute 'bd!' self.buf
if s:ptab == tab
wincmd p
endif
call s:pushd(self.dict) call s:pushd(self.dict)
try try
call s:callback(self.dict, self.temps) call s:callback(self.dict, self.temps)