mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 03:53:47 -05:00
Add backward compatibility for lambda.
Lambdas were introduced in Vim 7.4.2044.
This commit is contained in:
@@ -106,10 +106,17 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
|
|||||||
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
|
let cmd = gitgutter#utility#cd_cmd(a:bufnr, g:gitgutter_git_executable.' ls-files --error-unmatch --full-name '.gitgutter#utility#shellescape(s:filename(a:bufnr)))
|
||||||
|
|
||||||
if g:gitgutter_async && gitgutter#async#available()
|
if g:gitgutter_async && gitgutter#async#available()
|
||||||
|
if has('lambda')
|
||||||
call gitgutter#async#execute(cmd, a:bufnr, {
|
call gitgutter#async#execute(cmd, a:bufnr, {
|
||||||
\ 'out': {bufnr, path -> gitgutter#utility#setbufvar(bufnr, 'path', s:strip_trailing_new_line(path))},
|
\ 'out': {bufnr, path -> gitgutter#utility#setbufvar(bufnr, 'path', s:strip_trailing_new_line(path))},
|
||||||
\ 'err': {bufnr -> gitgutter#utility#setbufvar(bufnr, 'path', -2)},
|
\ 'err': {bufnr -> gitgutter#utility#setbufvar(bufnr, 'path', -2)},
|
||||||
\ })
|
\ })
|
||||||
|
else
|
||||||
|
call gitgutter#async#execute(cmd, a:bufnr, {
|
||||||
|
\ 'out': function('s:set_path'),
|
||||||
|
\ 'err': function('s:set_path', [-2])
|
||||||
|
\ })
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
let path = gitgutter#utility#system(cmd)
|
let path = gitgutter#utility#system(cmd)
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
@@ -120,6 +127,15 @@ function! gitgutter#utility#set_repo_path(bufnr) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:set_path(bufnr, path)
|
||||||
|
if a:bufnr == -2
|
||||||
|
let [bufnr, path] = [a:path, a:bufnr]
|
||||||
|
call gitgutter#utility#setbufvar(bufnr, 'path', path)
|
||||||
|
else
|
||||||
|
call gitgutter#utility#setbufvar(a:bufnr, 'path', s:strip_trailing_new_line(a:path))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
|
function! gitgutter#utility#cd_cmd(bufnr, cmd) abort
|
||||||
return 'cd '.s:dir(a:bufnr).' && '.a:cmd
|
return 'cd '.s:dir(a:bufnr).' && '.a:cmd
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user