Merge pull request 58 from killphi

This commit is contained in:
Marco Hinz 2013-08-20 15:49:14 +02:00
commit 09c7039f7c
2 changed files with 22 additions and 5 deletions

View File

@ -23,19 +23,19 @@ function! sy#start(path) abort
" new buffer.. add to list of registered files
if !has_key(g:sy, a:path)
if get(g:, 'signify_disable_by_default')
let g:sy[a:path] = { 'active': 0, 'type': 'unknown', 'hunks': [], 'id_top': g:id_top }
let g:sy[a:path] = { 'active': 0, 'type': 'unknown', 'hunks': [], 'id_top': g:id_top, 'stats': [0, 0, 0] }
return
endif
let [ diff, type ] = sy#repo#detect(a:path)
if empty(diff)
" register file as active with either no changes or no found VCS
let g:sy[a:path] = { 'active': 1, 'type': 'unknown', 'hunks': [], 'id_top': g:id_top }
let g:sy[a:path] = { 'active': 1, 'type': 'unknown', 'hunks': [], 'id_top': g:id_top, 'stats': [0, 0, 0] }
return
endif
" register file as active and containing changes
let g:sy[a:path] = { 'active': 1, 'type': type, 'hunks': [], 'id_top': g:id_top }
let g:sy[a:path] = { 'active': 1, 'type': type, 'hunks': [], 'id_top': g:id_top, 'stats': [0, 0, 0] }
" inactive buffer.. bail out
elseif !g:sy[a:path].active

View File

@ -133,6 +133,10 @@ endfunction
" Function: #process_diff {{{1
function! sy#repo#process_diff(path, diff) abort
let added = 0
let deleted = 0
let modified = 0
" Determine where we have to put our signs.
for line in filter(split(a:diff, '\n'), 'v:val =~ "^@@ "')
let tokens = matchlist(line, '^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)')
@ -148,6 +152,8 @@ function! sy#repo#process_diff(path, diff) abort
" +this is line 5
if (old_count == 0) && (new_count >= 1)
let added += new_count
let offset = 0
while offset < new_count
call add(signs, { 'type': 'SignifyAdd', 'lnum': new_line + offset, 'path': a:path })
@ -161,6 +167,8 @@ function! sy#repo#process_diff(path, diff) abort
" -this is line 7
elseif (old_count >= 1) && (new_count == 0)
let deleted += old_count
if new_line == 0
call add(signs, { 'type': 'SignifyDeleteFirstLine', 'lnum': 1, 'path': a:path })
else
@ -176,6 +184,8 @@ function! sy#repo#process_diff(path, diff) abort
" +this os line 6
elseif old_count == new_count
let modified += old_count
let offset = 0
while offset < new_count
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
@ -194,12 +204,15 @@ function! sy#repo#process_diff(path, diff) abort
" +this os line 6
if old_count > new_count
let modified += new_count
let deleted += (old_count - new_count)
let offset = 0
while offset < (new_count - 1)
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
let offset += 1
endwhile
let deleted = old_count - new_count
let deleted += (old_count - new_count)
call add(signs, { 'type': (deleted > 9) ? 'SignifyChangeDeleteMore' : 'SignifyChangeDelete'. deleted, 'lnum': new_line, 'path': a:path })
" lines changed and added:
@ -211,6 +224,8 @@ function! sy#repo#process_diff(path, diff) abort
" +this is line 666
else
let modified += old_count
let added += (new_count - old_count)
let offset = 0
while offset < old_count
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
@ -225,6 +240,8 @@ function! sy#repo#process_diff(path, diff) abort
call sy#sign#set(signs)
endfor
let g:sy[g:sy_path].stats = [added, modified, deleted]
endfunction
" vim: et sw=2 sts=2