From 24e9d4bdcdc4a0392c7aaa0906688d31f1cdb20e Mon Sep 17 00:00:00 2001 From: Andy Stewart Date: Mon, 25 Feb 2013 10:34:58 +0100 Subject: [PATCH] Clarify code. --- plugin/gitgutter.vim | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 02f1cf4..4dbbab0 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -102,20 +102,17 @@ function! s:process_hunk(hunk) let from_count = a:hunk[1] let to_line = a:hunk[2] let to_count = a:hunk[3] - " added - if from_count == 0 && to_count > 0 + if s:is_added(from_count, to_count) let offset = 0 while offset < to_count let line_number = to_line + offset call add(modifications, [line_number, 'added']) let offset += 1 endwhile - " removed - elseif from_count > 0 && to_count == 0 + elseif s:is_removed(from_count, to_count) " removed lines came after `to_line`. call add(modifications, [to_line, 'removed']) - " modified - else + else " modified let offset = 0 while offset < to_count let line_number = to_line + offset @@ -126,6 +123,14 @@ function! s:process_hunk(hunk) return modifications 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 {{{