Merge pull request 58 from killphi
This commit is contained in:
commit
09c7039f7c
@ -23,19 +23,19 @@ function! sy#start(path) abort
|
|||||||
" new buffer.. add to list of registered files
|
" new buffer.. add to list of registered files
|
||||||
if !has_key(g:sy, a:path)
|
if !has_key(g:sy, a:path)
|
||||||
if get(g:, 'signify_disable_by_default')
|
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
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let [ diff, type ] = sy#repo#detect(a:path)
|
let [ diff, type ] = sy#repo#detect(a:path)
|
||||||
if empty(diff)
|
if empty(diff)
|
||||||
" register file as active with either no changes or no found VCS
|
" 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
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" register file as active and containing changes
|
" 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
|
" inactive buffer.. bail out
|
||||||
elseif !g:sy[a:path].active
|
elseif !g:sy[a:path].active
|
||||||
|
@ -133,6 +133,10 @@ endfunction
|
|||||||
|
|
||||||
" Function: #process_diff {{{1
|
" Function: #process_diff {{{1
|
||||||
function! sy#repo#process_diff(path, diff) abort
|
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.
|
" Determine where we have to put our signs.
|
||||||
for line in filter(split(a:diff, '\n'), 'v:val =~ "^@@ "')
|
for line in filter(split(a:diff, '\n'), 'v:val =~ "^@@ "')
|
||||||
let tokens = matchlist(line, '^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)')
|
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
|
" +this is line 5
|
||||||
|
|
||||||
if (old_count == 0) && (new_count >= 1)
|
if (old_count == 0) && (new_count >= 1)
|
||||||
|
let added += new_count
|
||||||
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < new_count
|
while offset < new_count
|
||||||
call add(signs, { 'type': 'SignifyAdd', 'lnum': new_line + offset, 'path': a:path })
|
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
|
" -this is line 7
|
||||||
|
|
||||||
elseif (old_count >= 1) && (new_count == 0)
|
elseif (old_count >= 1) && (new_count == 0)
|
||||||
|
let deleted += old_count
|
||||||
|
|
||||||
if new_line == 0
|
if new_line == 0
|
||||||
call add(signs, { 'type': 'SignifyDeleteFirstLine', 'lnum': 1, 'path': a:path })
|
call add(signs, { 'type': 'SignifyDeleteFirstLine', 'lnum': 1, 'path': a:path })
|
||||||
else
|
else
|
||||||
@ -176,6 +184,8 @@ function! sy#repo#process_diff(path, diff) abort
|
|||||||
" +this os line 6
|
" +this os line 6
|
||||||
|
|
||||||
elseif old_count == new_count
|
elseif old_count == new_count
|
||||||
|
let modified += old_count
|
||||||
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < new_count
|
while offset < new_count
|
||||||
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
|
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
|
" +this os line 6
|
||||||
|
|
||||||
if old_count > new_count
|
if old_count > new_count
|
||||||
|
let modified += new_count
|
||||||
|
let deleted += (old_count - new_count)
|
||||||
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < (new_count - 1)
|
while offset < (new_count - 1)
|
||||||
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
|
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
|
||||||
let offset += 1
|
let offset += 1
|
||||||
endwhile
|
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 })
|
call add(signs, { 'type': (deleted > 9) ? 'SignifyChangeDeleteMore' : 'SignifyChangeDelete'. deleted, 'lnum': new_line, 'path': a:path })
|
||||||
|
|
||||||
" lines changed and added:
|
" lines changed and added:
|
||||||
@ -211,6 +224,8 @@ function! sy#repo#process_diff(path, diff) abort
|
|||||||
" +this is line 666
|
" +this is line 666
|
||||||
|
|
||||||
else
|
else
|
||||||
|
let modified += old_count
|
||||||
|
let added += (new_count - old_count)
|
||||||
let offset = 0
|
let offset = 0
|
||||||
while offset < old_count
|
while offset < old_count
|
||||||
call add(signs, { 'type': 'SignifyChange', 'lnum': new_line + offset, 'path': a:path })
|
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)
|
call sy#sign#set(signs)
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
let g:sy[g:sy_path].stats = [added, modified, deleted]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim: et sw=2 sts=2
|
" vim: et sw=2 sts=2
|
||||||
|
Loading…
Reference in New Issue
Block a user