diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-12 12:29:14 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-12-12 12:29:14 +0900 |
commit | f68017d21e78b23fbf648d579edb6500ae7a6de8 (patch) | |
tree | f39e7638b04ee4e39b243d88fc492994fe9c8c8f /plugin | |
parent | 2b725a4db5e973d7ce90d1ac0996dcfd3c3f0116 (diff) |
[windows/vim] Encode batchfile in current codepage
Backport https://github.com/junegunn/vim-plug/pull/913
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/fzf.vim | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 7781ae5f..fb12d9b6 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -49,18 +49,14 @@ if s:is_win " Use utf-8 for fzf.vim commands " Return array of shell commands for cmd.exe + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) function! s:wrap_cmds(cmds) - let use_chcp = executable('sed') return map([ \ '@echo off', \ 'setlocal enabledelayedexpansion'] - \ + (use_chcp ? [ - \ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a', - \ 'chcp 65001 > nul'] : []) \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) - \ + (use_chcp ? ['chcp !origchcp! > nul'] : []) \ + ['endlocal'], - \ 'v:val."\r"') + \ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage)) endfunction else let s:term_marker = ";#FZF" |