Improve GitGutter User autocommand: context/unsilent

This provides `g:gitgutter_hook_context` during the hook's execution and
removes the `:silent`, but uses `exists()` instead.

The bufnr might be necessary to know in the User autocommand, e.g. to
clear some cache.
Not using`:silent` is good practice in general to not hide (wanted)
output and errors etc.
This commit is contained in:
Daniel Hahler
2018-02-20 22:11:10 +01:00
committed by Andy Stewart
parent 4692457ae2
commit a046b5ace1
2 changed files with 7 additions and 1 deletions

View File

@@ -140,7 +140,11 @@ function! gitgutter#diff#handler(bufnr, diff) abort
endif
call s:save_last_seen_change(a:bufnr)
execute "silent doautocmd" s:nomodeline "User GitGutter"
if exists('#User#GitGutter')
let g:gitgutter_hook_context = {'bufnr': a:bufnr}
execute 'doautocmd' s:nomodeline 'User GitGutter'
unlet g:gitgutter_hook_context
endif
endfunction