diff options
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale.vim | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim index 9147b3a5..9c4be7d2 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -155,25 +155,20 @@ function! ale#Set(variable_name, default) abort return l:value endfunction -function! s:EscapePercents(str) abort - return substitute(a:str, '%', '%%', 'g') -endfunction - " Escape a string suitably for each platform. " shellescape does not work on Windows. function! ale#Escape(str) abort if fnamemodify(&shell, ':t') ==? 'cmd.exe' - if a:str =~# '\v^[a-zA-Z0-9-_\\/:%]+$' - return s:EscapePercents(a:str) - endif - - if a:str =~# ' ' - return '"' - \ . substitute(s:EscapePercents(a:str), '"', '""', 'g') - \ . '"' - endif - - return s:EscapePercents(substitute(a:str, '\v([&|<>^])', '^\1', 'g')) + " If the string contains spaces, it will be surrounded by quotes. + " Otherwise, special characters will be escaped with carets (^). + return substitute( + \ a:str =~# ' ' + \ ? '"' . substitute(a:str, '"', '""', 'g') . '"' + \ : substitute(a:str, '\v([&|<>^])', '^\1', 'g'), + \ '%', + \ '%%', + \ 'g', + \) endif return shellescape (a:str) |