Skip to content

Commit 81bfbce

Browse files
committed
System.AsyncProcess: Added support windows.
1 parent 62bc7ed commit 81bfbce

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

autoload/vital/__vital__/System/AsyncProcess.vim

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,39 @@ function! s:_vital_depends() abort
1616
return []
1717
endfunction
1818

19+
if s:is_windows
20+
" iconv() wrapper for safety.
21+
function! s:iconv(expr, from, to) abort
22+
if a:from ==# '' || a:to ==# '' || a:from ==? a:to
23+
return a:expr
24+
endif
25+
let result = iconv(a:expr, a:from, a:to)
26+
return result !=# '' ? result : a:expr
27+
endfunction
28+
endif
29+
1930
if !s:is_nvim
2031
" inner callbacks for Vim
2132
function! s:inner_out_cb(user_out_cb, ch, msg) abort
22-
call a:user_out_cb(a:msg)
33+
let result = a:msg
34+
if s:is_windows
35+
let result = s:iconv(a:msg, 'char', &encoding)
36+
endif
37+
38+
call a:user_out_cb(result)
2339
endfunction
2440

2541
function! s:inner_exit_cb(user_exit_cb, job, exit_code) abort
2642
call a:user_exit_cb(a:exit_code)
2743
endfunction
2844

2945
function! s:inner_err_cb(user_err_cb, ch, msg) abort
30-
call a:user_err_cb(a:msg)
46+
let result = a:msg
47+
if s:is_windows
48+
let result = s:iconv(a:msg, 'char', &encoding)
49+
endif
50+
51+
call a:user_err_cb(result)
3152
endfunction
3253
else
3354
" inner callbacks for Neovim

0 commit comments

Comments
 (0)