Skip to content

Commit

Permalink
Update only visible buffers on FocusGained and TabEnter.
Browse files Browse the repository at this point in the history
  • Loading branch information
airblade committed Apr 2, 2013
1 parent 15dc21a commit 93288af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
6 changes: 3 additions & 3 deletions README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ nmap <silent> ]h :<C-U>execute v:count1 . "GitGutterNextHunk"<CR>
nmap <silent> [h :<C-U>execute v:count1 . "GitGutterPrevHunk"<CR>
```

Finally, you can force vim-gitgutter to update its signs across all buffers with `:GitGutterAll`.
Finally, you can force vim-gitgutter to update its signs across all visible buffers with `:GitGutterAll`.

See the customisation section below for how to change the defaults.

Expand All @@ -81,7 +81,7 @@ You can customise:
* Whether or not signs are shown (defaults to yes)
* Whether or not line highlighting is on initially (defaults to off)
* Whether or not vim-gitgutter runs on `BufEnter` (defaults to yes)
* Whether or not vim-gitgutter runs for all buffers on `FocusGained` (defaults to yes)
* Whether or not vim-gitgutter runs for all visible buffers on `FocusGained` (defaults to yes)

Please note that vim-gitgutter won't override any colours or highlights you've set in your colorscheme.

Expand Down Expand Up @@ -173,7 +173,7 @@ let g:gitgutter_on_bufenter = 0
If you turn it off, vim-gitgutter will instead run every time you read or write a buffer.


#### To stop vim-gitgutter running for all buffers on `FocusGained`
#### To stop vim-gitgutter running for all visible buffers on `FocusGained`

This is on by default but causes a noticeable lag for some people. To turn it off, add this to your `~/.vimrc`:

Expand Down
17 changes: 6 additions & 11 deletions plugin/gitgutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ 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 @@ -399,7 +391,7 @@ endfunction
" Public interface {{{

function! GitGutterAll()
let buffer_ids = g:gitgutter_on_bufenter ? s:visible_buffers() : s:buffers()
let buffer_ids = g:gitgutter_on_bufenter ? tabpagebuflist() : s:buffers()
for buffer_id in buffer_ids
call GitGutter(expand('#' . buffer_id . ':p'))
endfor
Expand Down Expand Up @@ -524,8 +516,11 @@ augroup gitgutter
else
autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter(s:current_file())
endif
if g:gitgutter_all_on_focusgained && !has('gui_win32')
autocmd FocusGained * call GitGutterAll()
if g:gitgutter_all_on_focusgained
if !has('gui_win32')
autocmd FocusGained * call GitGutterAll()
endif
autocmd TabEnter * call GitGutterAll()
endif
augroup END

Expand Down

0 comments on commit 93288af

Please sign in to comment.