From fe2b4ec8692b79a99ef6c9cbdda6e39813b529b7 Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Wed, 13 Mar 2013 11:30:24 +0100 Subject: [PATCH] Place a dummy sign to keep sign column. The sign column automatically appears when there is at least one sign and disappears when there are none. There's a small gap between when vim-gitgutter removes its signs and adds new ones; during that gap the sign column can flicker. By adding a dummy sign before removing the real signs, we force the sign column to remain. --- plugin/gitgutter.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index b5669c5..e2da97a 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -29,6 +29,7 @@ function! s:init() let s:next_sign_id = s:first_sign_id let s:sign_ids = {} " key: filename, value: list of sign ids let s:other_signs = [] + let s:dummy_sign_id = 153 let g:gitgutter_initialised = 1 endif @@ -117,6 +118,7 @@ function! s:define_signs() sign define GitGutterLineModified sign define GitGutterLineRemoved sign define GitGutterLineModifiedRemoved + sign define GitGutterDummy call s:define_sign_symbols() call s:define_sign_text_highlights() @@ -350,6 +352,11 @@ function! s:is_other_sign(line_number) return index(s:other_signs, a:line_number) == -1 ? 0 : 1 endfunction +function! s:add_dummy_sign() + let last_line = line('$') + exe ":sign place " . s:dummy_sign_id . " line=" . (last_line + 1) . " name=GitGutterDummy file=" . s:current_file() +endfunction + " }}} " Public interface {{{ @@ -361,6 +368,7 @@ function! GitGutter() let s:hunks = s:parse_diff(diff) let modified_lines = s:process_hunks(s:hunks) let file_name = s:current_file() + call s:add_dummy_sign() call s:clear_signs(file_name) call s:find_other_signs(file_name) call s:show_signs(file_name, modified_lines)