I tried the following script which open fzf window two times.
In second opened fzf window, I need to press key 'a' or 'i' before select.
In first opened fzf window, it work normally.
function! s:git_other_branch()
return split(system("git branch | grep -v '*' | tr -d ' '"))
endfunction
function! s:git_ls_branch_diff(branch)
return split(system('git diff-tree --no-commit-id --name-only -r --diff-filter=ACMR '.a:branch.'..HEAD'))
endfunction
function! s:fzf_git_ls_branch_diff(branch)
call fzf#run({
\ 'source': <sid>git_ls_branch_diff(a:branch),
\ 'sink': 'e',
\ 'options': '+m',
\ 'down': '~40%'
\})
endfunction
nnoremap <silent> <Leader>fgb :call fzf#run({
\ 'source': <sid>git_other_branch(),
\ 'sink': function('<sid>fzf_git_ls_branch_diff'),
\ 'options': '+m',
\ 'down': '~40%'
\})<CR>
I would like to bump this issue up, as I have experienced the same.
Since the sink function is called within the exit_cb, I think fzf hasn't had a chance to clean up the previous invocation of fzf#run. The two invocactions are probably somehow stepping on each other. Feels like startinsert here https://github.com/junegunn/fzf/blob/ff951341c993ed84ad65344e496e122ee3dddf67/plugin/fzf.vim#L732 is getting clobbered by the cleanup of the previous fzf#run?
This would be awesome to fix
Have you tried calling feedkeys?
function! Sink(line)
call fzf#run({'sink': function('Sink'), 'right': '30%'})
if has('nvim')
call feedkeys('i', 'n')
endif
endfunction
call fzf#run({'sink': function('Sink'), 'right': '30%'})
Yes! That workaround works! Awesome.
Most helpful comment
Have you tried calling
feedkeys?