summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-06-21 21:45:10 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-06-21 21:45:10 +0900
commit355d004895eb8cb7e6ca7f8cf0b095f381d6e41b (patch)
tree2837f495fabbc7d218b67f5c59eef9ae45080051
parenta336494f5d8894f07c6d0297d408d59cd9185565 (diff)
[neovim] Fix error with {'window': 'enew'} (#274)0.10.0
-rw-r--r--plugin/fzf.vim33
1 files changed, 24 insertions, 9 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 48ad606e..cc463ded 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -248,13 +248,17 @@ function! s:calc_size(max, val)
endif
endfunction
+function! s:getpos()
+ return {'tab': tabpagenr(), 'win': winnr()}
+endfunction
+
function! s:split(dict)
let directions = {
\ 'up': ['topleft', 'resize', &lines],
\ 'down': ['botright', 'resize', &lines],
\ 'left': ['vertical topleft', 'vertical resize', &columns],
\ 'right': ['vertical botright', 'vertical resize', &columns] }
- let s:ptab = tabpagenr()
+ let s:ppos = s:getpos()
try
for [dir, triple] in items(directions)
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' }
function! fzf.on_exit(id, code)
- let tab = tabpagenr()
- if bufnr('') == self.buf
- " We use close instead of bd! since Vim does not close the split when
- " there's no other listed buffer
- close
- endif
- if s:ptab == tab
- wincmd p
+ let pos = s:getpos()
+ let inplace = pos == s:ppos " {'window': 'enew'}
+ if !inplace
+ if bufnr('') == self.buf
+ " We use close instead of bd! since Vim does not close the split when
+ " there's no other listed buffer (nvim +'set nobuflisted')
+ close
+ endif
+ if pos.tab == s:ppos.tab
+ wincmd p
+ endif
endif
call s:pushd(self.dict)
try
redraw!
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
call s:popd(self.dict)
endtry