diff --git a/README.mkd b/README.mkd index fd1164b..11706fd 100644 --- a/README.mkd +++ b/README.mkd @@ -63,7 +63,7 @@ nmap ]h :execute v:count1 . "GitGutterNextHunk" nmap [h :execute v:count1 . "GitGutterPrevHunk" ``` -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. @@ -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. @@ -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`: diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index ab62994..5e6554e 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -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 {{{ @@ -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 @@ -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