From 34e5e2dd8200fc2cf4b298cd2d5583f2875c7a70 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 14 May 2015 13:29:50 +0900 Subject: [PATCH] [vim] Use close+bufhidden=wipe instead of bd --- plugin/fzf.vim | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index ae266464..89794d95 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -272,7 +272,7 @@ function! s:split(dict) tabnew endif finally - setlocal winfixwidth winfixheight + setlocal winfixwidth winfixheight buftype=nofile bufhidden=wipe nobuflisted endtry endfunction @@ -283,10 +283,14 @@ function! s:execute_term(dict, command, temps) let fzf = { 'buf': bufnr('%'), 'dict': a:dict, 'temps': a:temps } function! fzf.on_exit(id, code) let tab = tabpagenr() - let wnr = winnr() - execute 'bd!' self.buf - if winnr() == wnr && tabpagenr() == tab + 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 + " FIXME This should be unnecessary due to `bufhidden=wipe` but in some + " cases Neovim fails to clean up the buffer and `bufexists('[FZF]') + " returns 1 even when it cannot be seen anywhere else. e.g. `FZF!` + silent! execute 'bd!' self.buf endif if s:ptab == tab wincmd p