diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 64e47cbeb8..1f8d21220b 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -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 { diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index 76197bc7e0..ef47ea7ed0 100644 --- a/test/functional/ui/linematch_spec.lua +++ b/test/functional/ui/linematch_spec.lua @@ -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') + 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('') + 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)