Skip to content

Commit a023694

Browse files
committed
Fix autocmd to use <abuf> for effective buffer
See airblade#814, airblade#607.
1 parent 256702d commit a023694

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

plugin/gitgutter.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ function! GitGutterCursorHold(timer)
248248
execute 'doautocmd' s:nomodeline 'gitgutter CursorHold'
249249
endfunction
250250

251+
function! s:next_tick(cmd)
252+
call timer_start(1, {-> execute(a:cmd)})
253+
endfunction
254+
251255
" Autocommands {{{
252256

253257
augroup gitgutter
@@ -264,9 +268,9 @@ augroup gitgutter
264268

265269
autocmd CursorHold,CursorHoldI * call gitgutter#process_buffer(bufnr(''), 0)
266270
if exists('*timer_start') && has('lambda')
267-
autocmd FileChangedShellPost * call timer_start(1, {-> gitgutter#process_buffer(bufnr(''), 1)})
271+
autocmd FileChangedShellPost * call s:next_tick("call gitgutter#process_buffer(+".expand('<abuf>').", 1)")
268272
else
269-
autocmd FileChangedShellPost * call gitgutter#process_buffer(bufnr(''), 1)
273+
autocmd FileChangedShellPost * call gitgutter#process_buffer(+expand('<abuf>'), 1)
270274
endif
271275

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

0 commit comments

Comments
 (0)