mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Fix missing empty string when LCS at one end
This commit is contained in:
@@ -102,8 +102,8 @@ function! s:diff(rline, aline, rlinenr, alinenr, rprefix, aprefix, regions, whol
|
|||||||
" two edits
|
" two edits
|
||||||
let lcs = s:lcs(rtext, atext)
|
let lcs = s:lcs(rtext, atext)
|
||||||
if len(lcs) > s:gap_between_regions
|
if len(lcs) > s:gap_between_regions
|
||||||
let redits = split(rtext, lcs)
|
let redits = split(rtext, lcs, 1)
|
||||||
let aedits = split(atext, lcs)
|
let aedits = split(atext, lcs, 1)
|
||||||
call s:diff(redits[0], aedits[0], a:rlinenr, a:alinenr, prefix+1, prefix+1, a:regions, 0)
|
call s:diff(redits[0], aedits[0], a:rlinenr, a:alinenr, prefix+1, prefix+1, a:regions, 0)
|
||||||
call s:diff(redits[1], aedits[1], a:rlinenr, a:alinenr, prefix+1+len(redits[0])+len(lcs), prefix+1+len(aedits[0])+len(lcs), a:regions, 0)
|
call s:diff(redits[1], aedits[1], a:rlinenr, a:alinenr, prefix+1+len(redits[0])+len(lcs), prefix+1+len(aedits[0])+len(lcs), a:regions, 0)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -952,6 +952,7 @@ function Test_common_suffix()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
" Note the order of lists within the overall returned list does not matter.
|
||||||
function Test_diff_highlight()
|
function Test_diff_highlight()
|
||||||
" Ignores mismatched number of added and removed lines.
|
" Ignores mismatched number of added and removed lines.
|
||||||
call assert_equal([], gitgutter#diff_highlight#process(['-foo']))
|
call assert_equal([], gitgutter#diff_highlight#process(['-foo']))
|
||||||
@@ -1022,6 +1023,13 @@ function Test_diff_highlight()
|
|||||||
" two edits
|
" two edits
|
||||||
let hunk = ['-The cat in the hat.', '+The ox in the box.']
|
let hunk = ['-The cat in the hat.', '+The ox in the box.']
|
||||||
call assert_equal([[1, '-', 6, 8], [2, '+', 6, 7], [1, '-', 17, 19], [2, '+', 16, 18]], gitgutter#diff_highlight#process(hunk))
|
call assert_equal([[1, '-', 6, 8], [2, '+', 6, 7], [1, '-', 17, 19], [2, '+', 16, 18]], gitgutter#diff_highlight#process(hunk))
|
||||||
|
|
||||||
|
" Requires s:gap_between_regions = 2 to pass.
|
||||||
|
" let hunk = ['-foo: bar.zap', '+foo: quux(bar)']
|
||||||
|
" call assert_equal([[2, '+', 7, 11], [1, '-', 10, 13], [2, '+', 15, 15]], gitgutter#diff_highlight#process(hunk))
|
||||||
|
|
||||||
|
let hunk = ['-gross_value: transaction.unexplained_amount', '+gross_value: amount(transaction)']
|
||||||
|
call assert_equal([[2, '+', 15, 21], [1, '-', 26, 44], [2, '+', 33, 33]], gitgutter#diff_highlight#process(hunk))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user