mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Fix calculation of removed lines for hunk summary.
This commit is contained in:
committed by
Andy Stewart
parent
6955f6dc91
commit
c44f4b8be6
@@ -243,6 +243,7 @@ function! s:parse_diff(diff)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:process_hunks(hunks)
|
function! s:process_hunks(hunks)
|
||||||
|
let s:hunk_summary = [0, 0, 0]
|
||||||
let modified_lines = []
|
let modified_lines = []
|
||||||
for hunk in a:hunks
|
for hunk in a:hunks
|
||||||
call extend(modified_lines, s:process_hunk(hunk))
|
call extend(modified_lines, s:process_hunk(hunk))
|
||||||
@@ -259,18 +260,25 @@ function! s:process_hunk(hunk)
|
|||||||
|
|
||||||
if s:is_added(from_count, to_count)
|
if s:is_added(from_count, to_count)
|
||||||
call s:process_added(modifications, from_count, to_count, to_line)
|
call s:process_added(modifications, from_count, to_count, to_line)
|
||||||
|
let s:hunk_summary[0] += to_count
|
||||||
|
|
||||||
elseif s:is_removed(from_count, to_count)
|
elseif s:is_removed(from_count, to_count)
|
||||||
call s:process_removed(modifications, from_count, to_count, to_line)
|
call s:process_removed(modifications, from_count, to_count, to_line)
|
||||||
|
let s:hunk_summary[2] += from_count
|
||||||
|
|
||||||
elseif s:is_modified(from_count, to_count)
|
elseif s:is_modified(from_count, to_count)
|
||||||
call s:process_modified(modifications, from_count, to_count, to_line)
|
call s:process_modified(modifications, from_count, to_count, to_line)
|
||||||
|
let s:hunk_summary[1] += to_count
|
||||||
|
|
||||||
elseif s:is_modified_and_added(from_count, to_count)
|
elseif s:is_modified_and_added(from_count, to_count)
|
||||||
call s:process_modified_and_added(modifications, from_count, to_count, to_line)
|
call s:process_modified_and_added(modifications, from_count, to_count, to_line)
|
||||||
|
let s:hunk_summary[0] += to_count - from_count
|
||||||
|
let s:hunk_summary[1] += from_count
|
||||||
|
|
||||||
elseif s:is_modified_and_removed(from_count, to_count)
|
elseif s:is_modified_and_removed(from_count, to_count)
|
||||||
call s:process_modified_and_removed(modifications, from_count, to_count, to_line)
|
call s:process_modified_and_removed(modifications, from_count, to_count, to_line)
|
||||||
|
let s:hunk_summary[1] += to_count
|
||||||
|
let s:hunk_summary[2] += from_count - to_count
|
||||||
|
|
||||||
endif
|
endif
|
||||||
return modifications
|
return modifications
|
||||||
@@ -346,24 +354,6 @@ function! s:process_modified_and_removed(modifications, from_count, to_count, to
|
|||||||
call add(a:modifications, [a:to_line + offset - 1, 'modified_removed'])
|
call add(a:modifications, [a:to_line + offset - 1, 'modified_removed'])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:update_hunk_summary(modified_lines)
|
|
||||||
let added = 0
|
|
||||||
let modified = 0
|
|
||||||
let removed = 0
|
|
||||||
for line in a:modified_lines
|
|
||||||
if match(line[1], 'added') > -1
|
|
||||||
let added += 1
|
|
||||||
endif
|
|
||||||
if match(line[1], 'modified') > -1
|
|
||||||
let modified += 1
|
|
||||||
endif
|
|
||||||
if match(line[1], 'removed') > -1
|
|
||||||
let removed += 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
let s:hunk_summary = [added, modified, removed]
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Sign processing {{{
|
" Sign processing {{{
|
||||||
@@ -476,7 +466,6 @@ function! GitGutter(file, ...)
|
|||||||
call s:clear_signs(a:file)
|
call s:clear_signs(a:file)
|
||||||
call s:find_other_signs(a:file)
|
call s:find_other_signs(a:file)
|
||||||
call s:show_signs(a:file, modified_lines)
|
call s:show_signs(a:file, modified_lines)
|
||||||
call s:update_hunk_summary(modified_lines)
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
command GitGutter call GitGutter(s:current_file())
|
command GitGutter call GitGutter(s:current_file())
|
||||||
|
|||||||
Reference in New Issue
Block a user