aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaehwang Jung <tomtomjhj@gmail.com>2023-08-12 18:14:37 +0900
committerGitHub <noreply@github.com>2023-08-12 17:14:37 +0800
commit5a25dcc5a4c73f50902432e32335ab073950cceb (patch)
tree5e99071e91b1235497bb17810d2c8051644a7742
parent04aed08157e324669f70fb0e90be38722332b3e1 (diff)
downloadrneovim-5a25dcc5a4c73f50902432e32335ab073950cceb.tar.gz
rneovim-5a25dcc5a4c73f50902432e32335ab073950cceb.tar.bz2
rneovim-5a25dcc5a4c73f50902432e32335ab073950cceb.zip
fix(diff): filler lines for hunks bigger than linematch limit (#24676)
Apply linematch filler computation only if the hunk is actually linematched. Fixes #24580
-rw-r--r--src/nvim/diff.c2
-rw-r--r--test/functional/ui/linematch_spec.lua44
2 files changed, 45 insertions, 1 deletions
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<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)