mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-09-27 12:49: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
|
" Use utf-8 for fzf.vim commands
|
||||||
" Return array of shell commands for cmd.exe
|
" Return array of shell commands for cmd.exe
|
||||||
let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0)
|
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)
|
function! s:wrap_cmds(cmds)
|
||||||
return map([
|
return map([
|
||||||
\ '@echo off',
|
\ '@echo off',
|
||||||
@ -57,7 +60,7 @@ if s:is_win
|
|||||||
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
|
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
|
||||||
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
||||||
\ + ['endlocal'],
|
\ + ['endlocal'],
|
||||||
\ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
|
\ '<SID>enc_to_cp(v:val."\r")')
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
let s:term_marker = ";#FZF"
|
let s:term_marker = ";#FZF"
|
||||||
@ -69,6 +72,10 @@ else
|
|||||||
function! s:wrap_cmds(cmds)
|
function! s:wrap_cmds(cmds)
|
||||||
return a:cmds
|
return a:cmds
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:enc_to_cp(str)
|
||||||
|
return a:str
|
||||||
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
function! s:shellesc_cmd(arg)
|
function! s:shellesc_cmd(arg)
|
||||||
@ -384,7 +391,7 @@ try
|
|||||||
let prefix = '( '.source.' )|'
|
let prefix = '( '.source.' )|'
|
||||||
elseif type == 3
|
elseif type == 3
|
||||||
let temps.input = s:fzf_tempname()
|
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).'|'
|
let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'
|
||||||
else
|
else
|
||||||
throw 'Invalid source type'
|
throw 'Invalid source type'
|
||||||
|
Loading…
Reference in New Issue
Block a user