Skip to content
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions plugin/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ if s:is_win
" Use utf-8 for fzf.vim commands
" Return array of shell commands for cmd.exe
function! s:wrap_cmds(cmds)
return map(['@echo off', 'for /f "tokens=4" %%a in (''chcp'') do set origchcp=%%a', 'chcp 65001 > nul'] +
return map(['@echo off'] +
\ (has('gui_running') ? ['set TERM= > nul'] : []) +
\ ['for /f "tokens=4" %%a in (''chcp'') do set origchcp=%%a', 'chcp 65001 > nul'] +
\ (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) +
\ ['chcp %origchcp% > nul'], 'v:val."\r"')
endfunction
Expand All @@ -75,7 +77,7 @@ function! s:shellesc_cmd(arg)
endfunction

function! fzf#shellescape(arg, ...)
let shell = get(a:000, 0, &shell)
let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh')
if shell =~# 'cmd.exe$'
return s:shellesc_cmd(a:arg)
endif
Expand Down Expand Up @@ -334,19 +336,20 @@ function! fzf#wrap(...)
endfunction

function! s:use_sh()
let [shell, shellslash] = [&shell, &shellslash]
let [shell, shellslash, shellcmdflag] = [&shell, &shellslash, &shellcmdflag]
if s:is_win
set shell=cmd.exe
set noshellslash
let &shellcmdflag = has('nvim') ? '/s /c' : '/c'
Comment thread
junegunn marked this conversation as resolved.
else
set shell=sh
endif
return [shell, shellslash]
return [shell, shellslash, shellcmdflag]
endfunction

function! fzf#run(...) abort
try
let [shell, shellslash] = s:use_sh()
let [shell, shellslash, shellcmdflag] = s:use_sh()

let dict = exists('a:1') ? s:upgrade(a:1) : {}
let temps = { 'result': s:fzf_tempname() }
Expand Down Expand Up @@ -416,7 +419,7 @@ try
call s:callback(dict, lines)
return lines
finally
let [&shell, &shellslash] = [shell, shellslash]
let [&shell, &shellslash, &shellcmdflag] = [shell, shellslash, shellcmdflag]
endtry
endfunction

Expand Down