Ver código fonte

output of chcp was not parsed correctly (#886)

* output of chcp was not parsed correctly

On Windows, when wrapping a batch command with the function s:wrap_cmds(),
when calling 'chcp' to get the current code page, the code assumed that
the output was in the format "active code page: XXX" (where XXX is the
code page), whereas the actual output is localized (for instance, in
French, the output would be: "page de code active: XXX").
The parsing of the output relied on that, and this failed for a
message different from "active code page" (i.e., English).

This patch changes the parsing to split the output of chcp on the colon
instead of spaces. Assuming that the output is always in the format
"<localized message>: XXX", regardless of the locale, hopefully, this is
a bit more robust.
gh4w 6 anos atrás
pai
commit
68b31a4a66
1 arquivos alterados com 2 adições e 2 exclusões
  1. 2 2
      plug.vim

+ 2 - 2
plug.vim

@@ -353,9 +353,9 @@ if s:is_win
 
   " Copied from fzf
   function! s:wrap_cmds(cmds)
-    return map(['@echo off', 'for /f "tokens=4" %%a in (''chcp'') do set origchcp=%%a', 'chcp 65001 > nul'] +
+    return map(['@echo off','setlocal enabledelayedexpansion','for /f "delims=: tokens=2" %%a in (''chcp'') do set origchcp=%%a','set origchcp=!origchcp: =!','chcp 65001 > nul'] +
     \ (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) +
-    \ ['chcp %origchcp% > nul'], 'v:val."\r"')
+    \ ['chcp !origchcp! > nul','setlocal disabledelayedexpansion'],'v:val."\r"')
   endfunction
 
   function! s:batchfile(cmd)