From d4a1a60f399ee4c6a16263e559dbcca70ed0a84a Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 10 Apr 2013 10:34:16 +0200 Subject: [PATCH] Always prevent flicker. Previously flicker was prevented only when the sign column was always present. --- README.mkd | 4 ---- plugin/gitgutter.vim | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.mkd b/README.mkd index 6f7a209..52b7a33 100644 --- a/README.mkd +++ b/README.mkd @@ -199,10 +199,6 @@ Note that this is always off with gVim on Windows due to a Vim/shell bug causing Your colorscheme is configuring the `SignColumn` highlight group weirdly. Please see the section above on customising the sign column. -> Why does the window flicker when the signs are redrawn? - -This happens on certain combinations of OS and Vim. You can prevent the flicker by adding `let g:gitgutter_sign_column_always = 1` to your `~/.vimrc`. - > There's a noticeable lag when vim-gitter runs; how can I avoid it? By default vim-gitgutter runs often so the signs are as accurate as possible. However on some systems this causes a noticeable lag. If you would like to trade a little accuracy for speed, add one or both of these to your `~/.vimrc`: diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index d66cc28..90f97f0 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -110,6 +110,10 @@ function! s:is_tracked_by_git() return !v:shell_error endfunction +function! s:differences(hunks) + return len(a:hunks) != 0 +endfunction + function! s:snake_case_to_camel_case(text) return substitute(a:text, '\v(.)(\a+)(_(.)(.+))?', '\u\1\l\2\u\4\l\5', '') endfunction @@ -417,6 +421,12 @@ function! GitGutter(file) let modified_lines = s:process_hunks(s:hunks) if g:gitgutter_sign_column_always call s:add_dummy_sign() + else + if s:differences(s:hunks) + call s:add_dummy_sign() " prevent flicker + else + call s:remove_dummy_sign() + endif endif call s:clear_signs(a:file) call s:find_other_signs(a:file)