junegunn / fzf.vim

fzf :heart: vim
MIT License
9.6k stars 583 forks source link

Preview window crashes for :Files and :RG #1562

Closed sheharyaar closed 4 weeks ago

sheharyaar commented 1 month ago

Checklist

Output of :echo system(fzf#exec() .. ' --version')

0.54.3 (af4917db)

OS

Problem / Steps to reproduce

When I use :Files: and :RG the preview window crashes, however when I use :Rg, :BLines and :FZF, the window works fine. I have tried reinstalling fzf and fzf.vim.

junegunn commented 1 month ago

Do you have bat installed?

sheharyaar commented 1 month ago

Yes, I have it installed in my system, when I use fzf from my terminal, it works well. The issue is happening only in Vim.

junegunn commented 1 month ago

What do you mean by "crash"? A screenshot?

sheharyaar commented 1 month ago

It opens and closes instantly.

junegunn commented 1 month ago

I can't reproduce the problem. Can you check if you still have the issue with the following minimal vimrc?

vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw)

(https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw)

sheharyaar commented 1 month ago

Happens with the minimal vimrc too.

junegunn commented 1 month ago

No clue. Vim version?

sheharyaar commented 1 month ago

Vim Version : VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Aug 11 2024 20:40:17)

sheharyaar commented 1 month ago

I tried a removing vim and all related files and reinstalling, still didn't work. I also tried switching both the binary and fzf to 0.52.0, but still didn't work.

junegunn commented 1 month ago

Does vim print any error messages? Have you checked the output of :messages?

sheharyaar commented 1 month ago

No messages there.

junegunn commented 1 month ago

Is this the first time you use fzf.vim, or did this suddenly happen after using fzf.vim for a while?

sheharyaar commented 1 month ago

This happened suddenly after using it for a while.

sheharyaar commented 4 weeks ago

This is something related to my terminal, I was using gnome-terminal with ayu theme from theme.sh, so when I ran :terminal it was spitting out RGB codes : ]10;rgb:0000/0000/0000]11;rgb:ffff/ffff/ffff, so when I reset the terminal, it works fine.

sheharyaar commented 4 weeks ago

Can this be a feature request : ignore color escape codes ?

junegunn commented 4 weeks ago

I'd say it's a configuration error. Your shell isn't supposed to output those codes in a non-interactive session. Try this and see if those codes are in the output.

$SHELL -c 'echo hello' > output
vim output

If the codes are in the output, it's going to break many scripts. You have to make sure to load theme.sh only in interactive mode by putting it in the right file that is only loaded in interactive mode or using a conditional branch like this

if [[ $- =~ i ]]; then
  # interactive stuff
fi

Related: https://github.com/junegunn/fzf/issues/1415#issuecomment-593817975

sheharyaar commented 4 weeks ago

The code gives output as hello in the vim window, however you are correct, I forgot to put my config under interactive condition for my shell. Putting it correctly, works! This can be closed now.