mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-09 20:13:46 -05:00
Fix independent toggling of signs in sign column and line highlights.
Note that line highlighting requires signs to be placed (because the line highlight is simply an attribute of a sign). If the user doesn't want to see signs in the sign column, but does want line highlighting, then we make the signs in the sign column invisible. If neither the signs in the sign column nor the line highlights are needed (presumably the user just looks at the hunks stats) then we can remove all signs, at which point Vim removes the sign column...unless the "sign column always" option is set.
This commit is contained in:
@@ -23,7 +23,7 @@ function! gitgutter#process_buffer(file, realtime)
|
||||
call hunk#set_hunks(diff#parse_diff(diff))
|
||||
let modified_lines = diff#process_hunks(hunk#hunks())
|
||||
|
||||
if g:gitgutter_signs
|
||||
if g:gitgutter_signs || g:gitgutter_highlight_lines
|
||||
call sign#update_signs(a:file, modified_lines)
|
||||
endif
|
||||
|
||||
@@ -77,19 +77,34 @@ endfunction
|
||||
function! gitgutter#line_highlights_disable()
|
||||
let g:gitgutter_highlight_lines = 0
|
||||
call highlight#define_sign_line_highlights()
|
||||
|
||||
if !g:gitgutter_signs
|
||||
call sign#clear_signs(utility#file())
|
||||
call sign#remove_dummy_sign(0)
|
||||
endif
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! gitgutter#line_highlights_enable()
|
||||
let old_highlight_lines = g:gitgutter_highlight_lines
|
||||
|
||||
let g:gitgutter_highlight_lines = 1
|
||||
call highlight#define_sign_line_highlights()
|
||||
|
||||
if !old_highlight_lines && !g:gitgutter_signs
|
||||
call gitgutter#all()
|
||||
endif
|
||||
|
||||
redraw!
|
||||
endfunction
|
||||
|
||||
function! gitgutter#line_highlights_toggle()
|
||||
let g:gitgutter_highlight_lines = !g:gitgutter_highlight_lines
|
||||
call highlight#define_sign_line_highlights()
|
||||
redraw!
|
||||
if g:gitgutter_highlight_lines
|
||||
call gitgutter#line_highlights_disable()
|
||||
else
|
||||
call gitgutter#line_highlights_enable()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}
|
||||
@@ -97,14 +112,24 @@ endfunction
|
||||
" Signs {{{
|
||||
|
||||
function! gitgutter#signs_enable()
|
||||
let old_signs = g:gitgutter_signs
|
||||
|
||||
let g:gitgutter_signs = 1
|
||||
call gitgutter#all()
|
||||
call highlight#define_sign_text_highlights()
|
||||
|
||||
if !old_signs && !g:gitgutter_highlight_lines
|
||||
call gitgutter#all()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! gitgutter#signs_disable()
|
||||
let g:gitgutter_signs = 0
|
||||
call sign#clear_signs(utility#file())
|
||||
call sign#remove_dummy_sign(0)
|
||||
call highlight#define_sign_text_highlights()
|
||||
|
||||
if !g:gitgutter_highlight_lines
|
||||
call sign#clear_signs(utility#file())
|
||||
call sign#remove_dummy_sign(0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! gitgutter#signs_toggle()
|
||||
|
||||
Reference in New Issue
Block a user