From 7808c48c7b06c88cfa79e9cd741360b84cdd048c Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 22 Aug 2022 09:30:47 +0100 Subject: [PATCH] Use timer instead of autocmd to defer startup processing If the user has removed the "gitgutter CursorHold" autocommand, which is the documented way to turn off automatic refreshing, calling the autocommand at start up will fail. Use a timer instead. This implementation also changes the processing delay to 1ms instead of 'updatetime'. See #840. --- plugin/gitgutter.vim | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 9e989ce..81dcc9c 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -245,8 +245,8 @@ function! s:on_bufenter() " been any changes to the buffer since the first round, the second round " will be cheap. if has('vim_starting') && !$VIM_GITGUTTER_TEST - if exists('*timer_start') - call timer_start(&updatetime, 'GitGutterCursorHold') + if exists('*timer_start') && has('lambda') + call s:next_tick("call gitgutter#process_buffer(+".bufnr('').", 0)") endif return endif @@ -259,10 +259,6 @@ function! s:on_bufenter() endif endfunction -function! GitGutterCursorHold(timer) - execute 'doautocmd' s:nomodeline 'gitgutter CursorHold' -endfunction - function! s:next_tick(cmd) call timer_start(1, {-> execute(a:cmd)}) endfunction