mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 19:43:47 -05:00
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:
committed by
Andy Stewart
parent
4692457ae2
commit
a046b5ace1
@@ -140,7 +140,11 @@ function! gitgutter#diff#handler(bufnr, diff) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
call s:save_last_seen_change(a:bufnr)
|
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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,8 @@ event GitGutter. You can listen for this event, for example:
|
|||||||
>
|
>
|
||||||
autocmd User GitGutter call updateMyStatusLine()
|
autocmd User GitGutter call updateMyStatusLine()
|
||||||
<
|
<
|
||||||
|
A dictionary `g:gitgutter_hook_context` is made available during its execution,
|
||||||
|
which contains an entry `bufnr` that contains the buffer number being updated.
|
||||||
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user