mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 12:03:48 -05:00
Remove unnecessary escaping.
While I can't say I fully understand escaping rules for Windows, I understand them better now than I did when I copied that code from another plugin and hoped for the best. As far as I can tell, this escaping code was written to be used when manually constructing a system command to execute – which isn't how this plugin is written. So this code shouldn't be here.
This commit is contained in:
@@ -23,7 +23,6 @@ function! diff#run_diff(realtime, use_external_grep)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
let cmd .= ')'
|
let cmd .= ')'
|
||||||
let cmd = utility#escape(cmd)
|
|
||||||
|
|
||||||
if a:realtime
|
if a:realtime
|
||||||
let diff = system(utility#command_in_directory_of_file(cmd), utility#buffer_contents())
|
let diff = system(utility#command_in_directory_of_file(cmd), utility#buffer_contents())
|
||||||
|
|||||||
@@ -57,18 +57,6 @@ function! utility#file_relative_to_repo_root()
|
|||||||
return substitute(s:file, repo_root_for_file, '', '')
|
return substitute(s:file, repo_root_for_file, '', '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" https://github.com/tpope/vim-dispatch/blob/bc415acd37187cbd6b417d92af40ba2c4b3b8775/autoload/dispatch/windows.vim#L8-L17
|
|
||||||
function! utility#escape(str)
|
|
||||||
if &shellxquote ==# '"'
|
|
||||||
return '"' . substitute(a:str, '"', '""', 'g') . '"'
|
|
||||||
else
|
|
||||||
let esc = exists('+shellxescape') ? &shellxescape : '"&|<>()@^'
|
|
||||||
return &shellquote .
|
|
||||||
\ substitute(a:str, '['.esc.']', '^&', 'g') .
|
|
||||||
\ get({'(': ')', '"(': ')"'}, &shellquote, &shellquote)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! utility#command_in_directory_of_file(cmd)
|
function! utility#command_in_directory_of_file(cmd)
|
||||||
let directory_of_file = shellescape(fnamemodify(utility#file(), ':h'))
|
let directory_of_file = shellescape(fnamemodify(utility#file(), ':h'))
|
||||||
return 'cd ' . directory_of_file . ' && ' . a:cmd
|
return 'cd ' . directory_of_file . ' && ' . a:cmd
|
||||||
|
|||||||
Reference in New Issue
Block a user