summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-12-16 00:41:03 -0500
committerJunegunn Choi <junegunn.c@gmail.com>2019-12-16 14:41:03 +0900
commit5da8bbf45af54df8f60969e88d95bf1fe155baee (patch)
tree87b7d267dc6f49598528f993b03e5a539758312d /plugin
parentaa0e10ead71cd9995bf6d6a01799e52551895816 (diff)
[vim] Encode list source to codepage (#1794)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/fzf.vim11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 0ce23b8e..0bbeaff9 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -50,6 +50,9 @@ 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:enc_to_cp(str)
+ return iconv(a:str, &encoding, 'cp'.s:codepage)
+ endfunction
function! s:wrap_cmds(cmds)
return map([
\ '@echo off',
@@ -57,7 +60,7 @@ if s:is_win
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
\ + ['endlocal'],
- \ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
+ \ '<SID>enc_to_cp(v:val."\r")')
endfunction
else
let s:term_marker = ";#FZF"
@@ -69,6 +72,10 @@ else
function! s:wrap_cmds(cmds)
return a:cmds
endfunction
+
+ function! s:enc_to_cp(str)
+ return a:str
+ endfunction
endif
function! s:shellesc_cmd(arg)
@@ -384,7 +391,7 @@ try
let prefix = '( '.source.' )|'
elseif type == 3
let temps.input = s:fzf_tempname()
- call writefile(source, temps.input)
+ call writefile(map(source, '<SID>enc_to_cp(v:val)'), temps.input)
let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'
else
throw 'Invalid source type'