mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Clarify code.
This commit is contained in:
@@ -102,20 +102,17 @@ function! s:process_hunk(hunk)
|
|||||||
let from_count = a:hunk[1]
|
let from_count = a:hunk[1]
|
||||||
let to_line = a:hunk[2]
|
let to_line = a:hunk[2]
|
||||||
let to_count = a:hunk[3]
|
let to_count = a:hunk[3]
|
||||||
" added
|
if s:is_added(from_count, to_count)
|
||||||
if from_count == 0 && to_count > 0
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < to_count
|
while offset < to_count
|
||||||
let line_number = to_line + offset
|
let line_number = to_line + offset
|
||||||
call add(modifications, [line_number, 'added'])
|
call add(modifications, [line_number, 'added'])
|
||||||
let offset += 1
|
let offset += 1
|
||||||
endwhile
|
endwhile
|
||||||
" removed
|
elseif s:is_removed(from_count, to_count)
|
||||||
elseif from_count > 0 && to_count == 0
|
|
||||||
" removed lines came after `to_line`.
|
" removed lines came after `to_line`.
|
||||||
call add(modifications, [to_line, 'removed'])
|
call add(modifications, [to_line, 'removed'])
|
||||||
" modified
|
else " modified
|
||||||
else
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < to_count
|
while offset < to_count
|
||||||
let line_number = to_line + offset
|
let line_number = to_line + offset
|
||||||
@@ -126,6 +123,14 @@ function! s:process_hunk(hunk)
|
|||||||
return modifications
|
return modifications
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:is_added(from_count, to_count)
|
||||||
|
return a:from_count == 0 && a:to_count > 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:is_removed(from_count, to_count)
|
||||||
|
return a:from_count > 0 && a:to_count == 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
" Sign processing {{{
|
" Sign processing {{{
|
||||||
|
|||||||
Reference in New Issue
Block a user