Speed up work done on FocusGained.

When vim-gitgutter is configured to update on `BufEnter`, which is the
default, we only need to update visible buffers on `FocusGained`.
Other buffers will be updated as and when the user enters them.
This commit is contained in:
Andy Stewart
2013-03-19 20:08:54 +01:00
parent fd7fb6cd15
commit 2a5ae179fc

View File

@@ -112,6 +112,14 @@ function! s:buffers()
return filter(range(1, bufnr('$')), 'buflisted(v:val)')
endfunction
function! s:visible_buffers()
let visible = []
for i in range(tabpagenr('$'))
call extend(visible, tabpagebuflist(i + 1))
endfor
return visible
endfunction
" }}}
" Highlights and signs {{{
@@ -388,7 +396,8 @@ endfunction
" Public interface {{{
function! GitGutterAll()
for buffer_id in s:buffers()
let buffer_ids = g:gitgutter_on_bufenter ? s:visible_buffers() : s:buffers()
for buffer_id in buffer_ids
call GitGutter(fnamemodify(bufname(buffer_id), ':p'))
endfor
endfunction