Skip to content

Commit

Permalink
Speed up work done on FocusGained.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
airblade committed Mar 19, 2013
1 parent fd7fb6c commit 2a5ae17
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 {{{
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2a5ae17

Please sign in to comment.