Skip to content

Commit

Permalink
Improve update detection when opening window
Browse files Browse the repository at this point in the history
  • Loading branch information
rbong committed Aug 26, 2024
1 parent 3b663f6 commit 67b696a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions autoload/flog/floggraph/buf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,30 @@ function! flog#floggraph#buf#FinishUpdateHook(bufnr) abort
return a:bufnr
endfunction

function! flog#floggraph#buf#ExecuteUpdateHookWhenSafe(bufnr) abort
if !exists('##SafeState')
return flog#floggraph#buf#FinishUpdateHook(a:bufnr)
endif

if bufnr() != a:bufnr
return -1
endif

let l:buf = string(a:bufnr)
augroup FlogGraphBufUpdate
exec 'autocmd! * <buffer=' . l:buf . '>'
exec 'autocmd SafeState <buffer=' . l:buf . '> call flog#floggraph#buf#FinishUpdateHook(' . l:buf . ')'
augroup END

return a:bufnr
endfunction

function! flog#floggraph#buf#InitUpdateHook(bufnr) abort
let l:buf = string(a:bufnr)

augroup FlogGraphBufUpdate
exec 'autocmd! * <buffer=' . l:buf . '>'
if exists('##SafeState')
exec 'autocmd SafeState <buffer=' . l:buf . '> call flog#floggraph#buf#FinishUpdateHook(' . l:buf . ')'
else
exec 'autocmd WinEnter <buffer=' . l:buf . '> call flog#floggraph#buf#FinishUpdateHook(' . l:buf . ')'
endif
exec 'autocmd BufEnter <buffer=' . l:buf . '> call flog#floggraph#buf#ExecuteUpdateHookWhenSafe(' . l:buf . ')'
augroup END

return a:bufnr
Expand Down

0 comments on commit 67b696a

Please sign in to comment.