fix(diff): filler lines for hunks bigger than linematch limit (#24676)

Apply linematch filler computation only if the hunk is actually
linematched.

Fixes #24580
This commit is contained in:
Jaehwang Jung 2023-08-12 18:14:37 +09:00 committed by GitHub
parent 04aed08157
commit 5a25dcc5a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 1 deletions

View File

@ -2384,7 +2384,7 @@ void diff_set_topline(win_T *fromwin, win_T *towin)
towin->w_topline = lnum + (dp->df_lnum[toidx] - dp->df_lnum[fromidx]);
if (lnum >= dp->df_lnum[fromidx]) {
if (diff_flags & DIFF_LINEMATCH) {
if (dp->is_linematched) {
calculate_topfill_and_topline(fromidx, toidx, fromwin->w_topline,
fromwin->w_topfill, &towin->w_topfill, &towin->w_topline);
} else {

View File

@ -1178,4 +1178,48 @@ describe('regressions', function()
helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' })
helpers.exec 'windo diffthis'
end)
it("properly computes filler lines for hunks bigger than linematch limit", function()
clear()
feed(':set diffopt+=linematch:10<cr>')
screen = Screen.new(100, 20)
screen:attach()
local lines = {}
for i = 0, 29 do
lines[#lines + 1] = tostring(i)
end
helpers.curbufmeths.set_lines(0, -1, false, lines)
helpers.exec 'vnew'
helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' })
helpers.exec 'windo diffthis'
feed('<C-e>')
screen:expect{grid=[[
{1: }{2:------------------------------------------------}│{1: }{3:^1 }|
{1: }{2:------------------------------------------------}│{1: }{3:2 }|
{1: }{2:------------------------------------------------}│{1: }{3:3 }|
{1: }{2:------------------------------------------------}│{1: }{3:4 }|
{1: }{2:------------------------------------------------}│{1: }{3:5 }|
{1: }{2:------------------------------------------------}│{1: }{3:6 }|
{1: }{2:------------------------------------------------}│{1: }{3:7 }|
{1: }{2:------------------------------------------------}│{1: }{3:8 }|
{1: }{2:------------------------------------------------}│{1: }{3:9 }|
{1: }{2:------------------------------------------------}│{1: }{3:10 }|
{1: }{2:------------------------------------------------}│{1: }{3:11 }|
{1: }{2:------------------------------------------------}│{1: }{3:12 }|
{1: }{2:------------------------------------------------}│{1: }{3:13 }|
{1: }{2:------------------------------------------------}│{1: }{3:14 }|
{1: }{2:------------------------------------------------}│{1: }{3:15 }|
{1: }{2:------------------------------------------------}│{1: }{3:16 }|
{1: }{2:------------------------------------------------}│{1: }{3:17 }|
{1: }29 {1: }{3:18 }|
{4:[No Name] [+] }{5:[No Name] [+] }|
|
]], attr_ids={
[1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey};
[2] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1};
[3] = {background = Screen.colors.LightBlue};
[4] = {reverse = true};
[5] = {reverse = true, bold = true};
}}
end)
end)