junegunn / fzf.vim

fzf :heart: vim
MIT License
9.62k stars 584 forks source link

Unfortunate interaction between tmux splits and nvim input/rpc calls #1476

Open expipiplus1 opened 1 year ago

expipiplus1 commented 1 year ago

If fzf.vim opens a tmux split or popup, nvim is locked until that split is dealt with.

By locked I mean:

Specifically this impacts coc-fzf, in that it uses a python script making an RPC call to nvim to populate the fzf buffer. The rpc call over the socket hangs, and no results are shown.

Not being able to process input is not the end of the world (after all, there's a big popup in the way), but not being able to populate the input to fzf is an issue.

I would guess that it's stuck in here: https://github.com/junegunn/fzf/blob/94999101e358385f3ca67a6ec9512f549196b802/plugin/fzf.vim#L717. I honestly have no idea if this is a simple one line change, or if it would require wobbling the whole of nvim's ui loop.

To reproduce:

To reproduce the rpc hang (untested):

from pynvim import attach
import sys
nvim = attach('socket', path=sys.argv[0])
nvim.command("echo hello")
print("something")

expipiplus1 commented 1 year ago

Possibly behind https://github.com/junegunn/fzf.vim/issues/1295

expipiplus1 commented 1 year ago

Ah, if I switch command here (https://github.com/junegunn/fzf/blob/94999101e358385f3ca67a6ec9512f549196b802/plugin/fzf.vim#L717) to jobstart then I get the expected contents in the fzf popup. (although obviously this doesn't allow capturing the results). jobwait([jobstart(command)]) sadly doesn't allow rpc calls to be processed while in jobwait :/ Busy waiting with 0 timeout seems to fail too.

expipiplus1 commented 1 year ago

Ah, this seems to work, great!

  let fzf = {}
  let fzf.dict = a:dict
  let fzf.temps = a:temps
  function! fzf.on_exit(job_id, exit_status, event) dict
    call s:pushd(self.dict)
    let lines = s:collect(self.temps)
    call s:callback(self.dict, lines)
  endfunction
  call jobstart(command, fzf)
  return []