Skip to content

Commit

Permalink
Fix autocmd to use <abuf> for effective buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Jan 29, 2022
1 parent 256702d commit a023694
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ function! GitGutterCursorHold(timer)
execute 'doautocmd' s:nomodeline 'gitgutter CursorHold'
endfunction

function! s:next_tick(cmd)
call timer_start(1, {-> execute(a:cmd)})
endfunction

" Autocommands {{{

augroup gitgutter
Expand All @@ -264,9 +268,9 @@ augroup gitgutter

autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
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
autocmd FileChangedShellPost * call gitgutter#process_buffer(bufnr(''), 1)
autocmd FileChangedShellPost * call gitgutter#process_buffer(+expand('<abuf>'), 1)
endif

" Ensure that all buffers are processed when opening vim with multiple files, e.g.:
Expand Down

0 comments on commit a023694

Please sign in to comment.