mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-11 05:53:16 +08:00
[fzf#vim#with_preview] Detect WSL bash on Windows only
Close https://github.com/junegunn/fzf.vim/issues/1052
This commit is contained in:
committed by
Junegunn Choi
parent
18205e071d
commit
3348aef05d
@@ -76,8 +76,6 @@ endfunction
|
||||
|
||||
" [[spec to wrap], [preview window expression], [toggle-preview keys...]]
|
||||
function! fzf#vim#with_preview(...)
|
||||
let bash_path = exepath('bash')
|
||||
let is_wsl_bash = bash_path =~? 'Windows[/\\]system32[/\\]bash.exe$'
|
||||
" Default spec
|
||||
let spec = {}
|
||||
let window = ''
|
||||
@@ -90,7 +88,7 @@ function! fzf#vim#with_preview(...)
|
||||
call remove(args, 0)
|
||||
endif
|
||||
|
||||
if empty(bash_path)
|
||||
if !executable('bash')
|
||||
if !s:warned
|
||||
call s:warn('Preview window not supported (bash not found in PATH)')
|
||||
let s:warned = 1
|
||||
@@ -115,6 +113,7 @@ function! fzf#vim#with_preview(...)
|
||||
let preview += ['--preview-window', window]
|
||||
endif
|
||||
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, '\'))
|
||||
|
||||
Reference in New Issue
Block a user