mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-09-28 05:09:02 +00:00
[vim] Encode list source to codepage (#1794)
This commit is contained in:
parent
aa0e10ead7
commit
5da8bbf45a
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user