junegunn / fzf.vim

fzf :heart: vim
MIT License
9.66k stars 585 forks source link

:Rg test failed #1099

Open UKeeySDis opened 4 years ago

UKeeySDis commented 4 years ago

I saw similar issues like this one, but they provided empty query, I'm not. image I can run this command in terminal success. rg version: image

This is my .vimrc about fzf:

  function! RipgrepFzf(query, fullscreen)
    let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s '
    let initial_command = printf(command_fmt, shellescape(a:query))
    let reload_command = printf(command_fmt, '{q}')
    let options = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
    call fzf#vim#grep(initial_command, 1, options, a:fullscreen)
  endfunction

  command! -nargs=1 -bang Rg call RipgrepFzf(<q-args>, <bang>0)
aldenjenkins commented 4 years ago

:Rg returns command not found for me, too

junegunn commented 4 years ago

Run the command in the error message in your shell and check the exit code. If it's non-zero, fzf displays the message.

UKeeySDis commented 4 years ago

Run the command in the error message in your shell and check the exit code. If it's non-zero, fzf displays the message.

I check the exit code by run echo $? in my shell, but the result is zero.

UKeeySDis commented 4 years ago

:Rg returns command not found for me, too

maybe u should run rg in your shell first.

wezm commented 4 years ago

This rg man page says:

If ripgrep finds a match, then the exit status of the program is 0. If no match could be found, then the exit status is 1. If an error occurred, then the exit status is always 2 unless ripgrep was run with the --quiet flag and a match was found.

The fzf code appears to report the "Command failed" error if the command didn't exit with status 0 and produced no output, which is the case when ripgrep matching no lines.

https://github.com/junegunn/fzf/blob/c60ed1758315f0d993fbcbf04459944c87e19a48/src/terminal.go#L869-L871

So, I think that for no search results this is the expected behaviour.