mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-23 20:41:30 +08:00
[fzf#vim#preview] works with Windows default command (#441)
This commit is contained in:
committed by
Junegunn Choi
parent
0b0d9f0912
commit
df79877245
@@ -32,7 +32,7 @@ let s:is_win = has('win32') || has('win64')
|
|||||||
let s:layout_keys = ['window', 'up', 'down', 'left', 'right']
|
let s:layout_keys = ['window', 'up', 'down', 'left', 'right']
|
||||||
let s:bin_dir = expand('<sfile>:h:h:h').'/bin/'
|
let s:bin_dir = expand('<sfile>:h:h:h').'/bin/'
|
||||||
let s:bin = {
|
let s:bin = {
|
||||||
\ 'preview': s:bin_dir.(executable('ruby') ? 'preview.rb' : 'preview.sh'),
|
\ 'preview': s:bin_dir.(!s:is_win && executable('ruby') ? 'preview.rb' : 'preview.sh'),
|
||||||
\ 'tags': s:bin_dir.'tags.pl' }
|
\ 'tags': s:bin_dir.'tags.pl' }
|
||||||
let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
|
let s:TYPE = {'dict': type({}), 'funcref': type(function('call')), 'string': type(''), 'list': type([])}
|
||||||
if s:is_win
|
if s:is_win
|
||||||
@@ -41,7 +41,7 @@ if s:is_win
|
|||||||
else
|
else
|
||||||
let s:bin.preview = fnamemodify(s:bin.preview, ':8')
|
let s:bin.preview = fnamemodify(s:bin.preview, ':8')
|
||||||
endif
|
endif
|
||||||
let s:bin.preview = escape(s:bin.preview, '\')
|
let s:bin.preview = 'bash '.escape(s:bin.preview, '\')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:merge_opts(dict, eopts)
|
function! s:merge_opts(dict, eopts)
|
||||||
@@ -204,10 +204,6 @@ function! s:fzf(name, opts, extra)
|
|||||||
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
|
let eopts = has_key(extra, 'options') ? remove(extra, 'options') : ''
|
||||||
let merged = extend(copy(a:opts), extra)
|
let merged = extend(copy(a:opts), extra)
|
||||||
call s:merge_opts(merged, eopts)
|
call s:merge_opts(merged, eopts)
|
||||||
let mopts = get(merged, 'options', '')
|
|
||||||
if s:is_win && empty(get(merged, 'source', '')) && empty($FZF_DEFAULT_COMMAND) && (type(mopts) == s:TYPE.list ? join(mopts) : mopts) =~# s:bin.preview
|
|
||||||
return s:warn('preview script is incompatible with the default command in Windows')
|
|
||||||
endif
|
|
||||||
return fzf#run(s:wrap(a:name, merged, bang))
|
return fzf#run(s:wrap(a:name, merged, bang))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,11 @@ IFS=':' read -r -a INPUT <<< "$1"
|
|||||||
FILE=${INPUT[0]}
|
FILE=${INPUT[0]}
|
||||||
CENTER=${INPUT[1]}
|
CENTER=${INPUT[1]}
|
||||||
|
|
||||||
|
if [[ $1 =~ ^[A-Z]:\\ ]]; then
|
||||||
|
FILE=$FILE:${INPUT[1]}
|
||||||
|
CENTER=${INPUT[2]}
|
||||||
|
fi
|
||||||
|
|
||||||
if [ ! -r "$FILE" ]; then
|
if [ ! -r "$FILE" ]; then
|
||||||
echo "File not found ${FILE}"
|
echo "File not found ${FILE}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user