Fix autocmd to use <abuf> for effective buffer

See #814, #607.
This commit is contained in:
Andy Stewart
2022-01-29 15:08:40 +00:00
parent 256702dd14
commit a02369403b

View File

@@ -248,6 +248,10 @@ function! GitGutterCursorHold(timer)
execute 'doautocmd' s:nomodeline 'gitgutter CursorHold' execute 'doautocmd' s:nomodeline 'gitgutter CursorHold'
endfunction endfunction
function! s:next_tick(cmd)
call timer_start(1, {-> execute(a:cmd)})
endfunction
" Autocommands {{{ " Autocommands {{{
augroup gitgutter augroup gitgutter
@@ -264,9 +268,9 @@ augroup gitgutter
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0) autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
if exists('*timer_start') && has('lambda') if exists('*timer_start') && has('lambda')
autocmd FileChangedShellPost * call timer_start(1, {-> gitgutter#process_buffer(bufnr(''), 1)}) autocmd FileChangedShellPost * call s:next_tick("call gitgutter#process_buffer(+".expand('<abuf>').", 1)")
else else
autocmd FileChangedShellPost * call gitgutter#process_buffer(bufnr(''), 1) autocmd FileChangedShellPost * call gitgutter#process_buffer(+expand('<abuf>'), 1)
endif endif
" Ensure that all buffers are processed when opening vim with multiple files, e.g.: " Ensure that all buffers are processed when opening vim with multiple files, e.g.: