From d40d34aaa5720b67da629b4ca74674dfd4b9221c Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Mon, 12 Dec 2022 16:44:11 +0000 Subject: fix(diff): handle long lines without crashing (#21389) Fixes https://github.com/neovim/neovim/issues/21388 --- test/functional/ui/linematch_spec.lua | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index 5601908929..697677aa67 100644 --- a/test/functional/ui/linematch_spec.lua +++ b/test/functional/ui/linematch_spec.lua @@ -49,12 +49,11 @@ describe('Diff mode screen with 3 diffs open', function() [8] = {background = Screen.colors.Red1, bold = true}; [10] = {foreground = Screen.colors.Brown}; [9] = {background = Screen.colors.Plum1}; -}) + }) feed('=') feed(':windo set nu!') - - end) + describe('setup the diff screen to look like a merge conflict with 3 files in diff mode', function() before_each(function() @@ -249,12 +248,11 @@ describe('Diff mode screen with 2 diffs open', function() [8] = {background = Screen.colors.Red1, bold = true}; [10] = {foreground = Screen.colors.Brown}; [9] = {background = Screen.colors.Plum1}; -}) + }) feed('=') feed(':windo set nu!') - - end) + describe('setup a diff with 2 files and set linematch:30', function() before_each(function() feed(':set diffopt+=linematch:30') @@ -979,3 +977,19 @@ something end) end) end) + +describe('regressions', function() + local screen + + it("doesn't crash with long lines", function() + clear() + feed(':set diffopt+=linematch:30') + screen = Screen.new(100, 20) + screen:attach() + -- line must be greater than MATCH_CHAR_MAX_LEN + helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1000)..'hello' }) + helpers.exec 'vnew' + helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' }) + helpers.exec 'windo diffthis' + end) +end) -- cgit