Fix non-empty suffix condition

This commit is contained in:
Andy Stewart
2019-09-23 13:19:49 +01:00
parent f980fab55c
commit ae9edf0602
2 changed files with 7 additions and 2 deletions

View File

@@ -40,11 +40,11 @@ function! gitgutter#diff_highlight#process(hunk_body)
let prefix = s:common_prefix(rline, aline)
let [rsuffix, asuffix] = s:common_suffix(rline, aline, prefix+1)
if (prefix != 0 || rsuffix != 0) && prefix+1 < rsuffix
if (prefix != 0 || rsuffix != len(rline)) && prefix+1 < rsuffix
call add(regions, [i+1, '-', prefix+1+1, rsuffix+1-1])
endif
if (prefix != 0 || asuffix != 0) && prefix+1 < asuffix
if (prefix != 0 || asuffix != len(aline)) && prefix+1 < asuffix
call add(regions, [i+1+removed, '+', prefix+1+1, asuffix+1-1])
endif
endfor

View File

@@ -947,6 +947,11 @@ function Test_diff_highlight()
call assert_equal([], gitgutter#diff_highlight#process(['+foo']))
call assert_equal([], gitgutter#diff_highlight#process(['-foo','-bar','+baz']))
" everything changed
let hunk = ['-foo', '+cat']
let expected = []
call assert_equal(expected, gitgutter#diff_highlight#process(hunk))
" change in middle
let hunk = ['-foo bar baz', '+foo (bar) baz']
let expected = [[1, '-', 6, 8], [2, '+', 6, 10]]