Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview broken by default on linux with powershell #1139

Open
5 tasks done
eruizc-dev opened this issue Oct 16, 2020 · 1 comment
Open
5 tasks done

Preview broken by default on linux with powershell #1139

eruizc-dev opened this issue Oct 16, 2020 · 1 comment

Comments

@eruizc-dev
Copy link

eruizc-dev commented Oct 16, 2020


Issue

On a fresh install executing :Files causes the preview to display the following error:

image

The execution of the preview script fails, I assume it's due to the use of single quotes instead of double quotes.

Workaround

I had to override Files command like shown in the fzf.vim readme for it to work

" .vimrc
command! -bang -nargs=? -complete=dir Files
    \ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', '~/.vim/plugged/fzf.vim/bin/preview.sh {}']}, <bang>0)

Although this is not perfect since all commands that call fzf#vim#with_preview have the exact same error, like :Rg and must be tweaked independently.


System info

  • OS: Manjaro Linux x86_64
  • Desktop: Plasma 5.19.5
  • Shell: pwsh PowerShell 7.0.3
  • fzf: 0.22.0
  • vim: Vi Improved 8.2
@eruizc-dev
Copy link
Author

eruizc-dev commented Oct 20, 2020

I managed to "fix" this issue by changing the following:

" autoload/fzf/vim.vim line 31
" plugin/fzf.vim line 26
" autoload/fzf/vim/complete.vim line 26
let s:is_win = 1

I guess it's assuming shell based on the OS rather than checking for the shell by itself. I saw some code checking for wsl too.
A proper fix would be to have s:is_win check for cmd/powershell/pwsh rather than win32/win64.


Edit:

More specifically, it's the if condition in fzf.vim line 150

  if s:is_win
    let is_wsl_bash = exepath('bash') =~? 'Windows[/\\]system32[/\\]bash.exe$'
    let preview_cmd = 'bash '.(is_wsl_bash
    \ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/mnt/\L\1', ''), '\', '/', 'g')
    \ : escape(s:bin.preview, '\'))
  else
    let preview_cmd = fzf#shellescape(s:bin.preview)
  endif

It assumes that if you're not in windows you're using bash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant