[vim] Use cmd.exe in Windows (#785)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Jan Edmund Lazo · committed by Junegunn Choi · parent 45faad7 · Browse files · 1 file·+30 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+30 added−6 removed
- other:+30 added−6 removed
Provenance
- Commit
42a2371- Tree
cfb9d3c- Author
Jan Edmund Lazo <janlazo@users.noreply.github.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
45faad7
1 file changed+30 added−6 removed
modified:plugin/fzf.vim+30 added-6 removed
78 unmodified lines79 return '"'.substitute(a:arg, '"', '\\"', 'g').'"'80 endfunction81 82 function! s:escape(path)83+ let escaped_chars = '$%#''"'84+85+ if has('unix')86+ let escaped_chars .= ' \'87+ endif88+83- return escape(a:path, ' $%#''"\')89+ return escape(a:path, escaped_chars)90 endfunction91 92 " Upgrade legacy options93 function! s:upgrade(dict)145 unmodified lines239 240 function! fzf#run(...) abort241 try242 let oshell = &shell243+ let useshellslash = &shellslash244+245+ if has('win32') || has('win64')246+ set shell=cmd.exe247+ set shellslash248+ else237- set shell=sh249+ set shell=sh250+ endif251+252 if has('nvim') && len(filter(range(1, bufnr('$')), 'bufname(v:val) =~# ";#FZF"'))253 call s:warn('FZF is already running!')254 return []255 endif8 unmodified lines264 265 if !has_key(dict, 'source') && !empty($FZF_DEFAULT_COMMAND)266 let temps.source = tempname()267 call writefile(split($FZF_DEFAULT_COMMAND, "\n"), temps.source)254- let dict.source = (empty($SHELL) ? 'sh' : $SHELL) . ' ' . s:shellesc(temps.source)268+ let dict.source = (empty($SHELL) ? &shell : $SHELL) . ' ' . s:shellesc(temps.source)269 endif270 271 if has_key(dict, 'source')272 let source = dict.source21 unmodified lines294 call s:callback(dict, lines)295 return lines296 finally297 let &shell = oshell298+ let &shellslash = useshellslash299 endtry300 endfunction301 302 function! s:present(dict, ...)64 unmodified lines367 \ synIDattr(hlID("Normal"), "bg"), synIDattr(hlID("Normal"), "fg"),368 \ &columns, &lines/2, getwinposx(), getwinposy())369 endfunction370 unlet! s:launcher371+if has('win32') || has('win64')372+ let s:launcher = 'cmd.exe /C %s'373+else356-let s:launcher = function('s:xterm_launcher')374+ let s:launcher = function('s:xterm_launcher')375+endif376 377 function! s:exit_handler(code, command, ...)378 if a:code == 130379 return 08 unmodified lines388 endfunction389 390 function! s:execute(dict, command, temps) abort391 call s:pushd(a:dict)392+ if has('unix')373- silent! !clear 2> /dev/null393+ silent! !clear 2> /dev/null394+ endif395 let escaped = escape(substitute(a:command, '\n', '\\n', 'g'), '%#')396 if has('gui_running')397 let Launcher = get(a:dict, 'launcher', get(g:, 'Fzf_launcher', get(g:, 'fzf_launcher', s:launcher)))398 let fmt = type(Launcher) == 2 ? call(Launcher, []) : Launcher378- let command = printf(fmt, "'".substitute(escaped, "'", "'\"'\"'", 'g')."'")399+ if has('unix')400+ let escaped = "'".substitute(escaped, "'", "'\"'\"'", 'g')."'"401+ endif402+ let command = printf(fmt, escaped)403 else404 let command = escaped405 endif406 execute 'silent !'.command224 unmodified lines