[neovim] Fix error with {'window': 'enew'} (#274)

This commit is contained in:
Junegunn Choi 2015-06-21 21:45:10 +09:00
parent a336494f5d
commit 355d004895

View File

@ -248,13 +248,17 @@ function! s:calc_size(max, val)
endif endif
endfunction endfunction
function! s:getpos()
return {'tab': tabpagenr(), 'win': winnr()}
endfunction
function! s:split(dict) function! s:split(dict)
let directions = { let directions = {
\ 'up': ['topleft', 'resize', &lines], \ 'up': ['topleft', 'resize', &lines],
\ 'down': ['botright', 'resize', &lines], \ 'down': ['botright', 'resize', &lines],
\ 'left': ['vertical topleft', 'vertical resize', &columns], \ 'left': ['vertical topleft', 'vertical resize', &columns],
\ 'right': ['vertical botright', 'vertical resize', &columns] } \ 'right': ['vertical botright', 'vertical resize', &columns] }
let s:ptab = tabpagenr() let s:ppos = s:getpos()
try try
for [dir, triple] in items(directions) for [dir, triple] in items(directions)
let val = get(a:dict, dir, '') let val = get(a:dict, dir, '')
@ -282,19 +286,30 @@ function! s:execute_term(dict, command, temps)
let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps, 'name': 'FZF' } let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps, 'name': 'FZF' }
function! fzf.on_exit(id, code) function! fzf.on_exit(id, code)
let tab = tabpagenr() let pos = s:getpos()
if bufnr('') == self.buf let inplace = pos == s:ppos " {'window': 'enew'}
" We use close instead of bd! since Vim does not close the split when if !inplace
" there's no other listed buffer if bufnr('') == self.buf
close " We use close instead of bd! since Vim does not close the split when
endif " there's no other listed buffer (nvim +'set nobuflisted')
if s:ptab == tab close
wincmd p endif
if pos.tab == s:ppos.tab
wincmd p
endif
endif endif
call s:pushd(self.dict) call s:pushd(self.dict)
try try
redraw! redraw!
call s:callback(self.dict, self.temps) call s:callback(self.dict, self.temps)
if inplace && bufnr('') == self.buf
execute "normal! \<c-^>"
" No other listed buffer
if bufnr('') == self.buf
bd!
endif
endif
finally finally
call s:popd(self.dict) call s:popd(self.dict)
endtry endtry