diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:40:31 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:40:31 +0000 |
commit | 339e2d15cc26fe86988ea06468d912a46c8d6f29 (patch) | |
tree | a6167fc8fcfc6ae2dc102f57b2473858eac34063 /test/functional/ui/linematch_spec.lua | |
parent | 067dc73729267c0262438a6fdd66e586f8496946 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.tar.gz rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.tar.bz2 rneovim-339e2d15cc26fe86988ea06468d912a46c8d6f29.zip |
Merge remote-tracking branch 'upstream/master' into fix_repeatcmdline
Diffstat (limited to 'test/functional/ui/linematch_spec.lua')
-rw-r--r-- | test/functional/ui/linematch_spec.lua | 230 |
1 files changed, 230 insertions, 0 deletions
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index 697677aa67..ef47ea7ed0 100644 --- a/test/functional/ui/linematch_spec.lua +++ b/test/functional/ui/linematch_spec.lua @@ -779,6 +779,192 @@ something end) end) + describe('setup a diff with 2 files and set linematch:30', function() + before_each(function() + feed(':set diffopt+=linematch:30<cr>') + local f1 = [[ +// abc d +// d +// d + ]] + local f2 = [[ + +abc d +d + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^ }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{9:abc d }│{1: }{10: 1 }{8:// }{9:abc d }| + {1: }{10: 3 }{9:d }│{1: }{10: 2 }{8:// }{9:d }| + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 3 }{4:// d }| + {1: }{10: 4 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('setup a diff with 2 files and set linematch:30, with ignore white', function() + before_each(function() + feed(':set diffopt+=linematch:30<cr>:set diffopt+=iwhiteall<cr>') + local f1 = [[ +void testFunction () { + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + } + } +} + ]] + local f2 = [[ +void testFunction () { + // for (int j = 0; j < 10; i++) { + // } +} + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }^void testFunction () { │{1: }{10: 1 }void testFunction () { | + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 2 }{4: for (int i = 0; i < 10; i++) { }| + {1: }{10: 2 }{9: }{8:// for (int j = 0; j < 10; i}{9:++) { }│{1: }{10: 3 }{9: }{8:for (int j = 0; j < 10; j}{9:++) { }| + {1: }{10: 3 }{9: }{8:// }{9:} }│{1: }{10: 4 }{9: } }| + {1: }{10: }{2:-------------------------------------------}│{1: }{10: 5 }{4: } }| + {1: }{10: 4 }} │{1: }{10: 6 }} | + {1: }{10: 5 } │{1: }{10: 7 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('a diff that would result in multiple groups before grouping optimization', function() + before_each(function() + feed(':set diffopt+=linematch:30<cr>') + local f1 = [[ +!A +!B +!C + ]] + local f2 = [[ +?Z +?A +?B +?C +?A +?B +?B +?C + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^?Z }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{8:?}{9:A }│{1: }{10: 1 }{8:!}{9:A }| + {1: }{10: 3 }{8:?}{9:B }│{1: }{10: 2 }{8:!}{9:B }| + {1: }{10: 4 }{8:?}{9:C }│{1: }{10: 3 }{8:!}{9:C }| + {1: }{10: 5 }{4:?A }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 6 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 7 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 8 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 9 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) + describe('a diff that would result in multiple groups before grouping optimization', function() + before_each(function() + feed(':set diffopt+=linematch:30<cr>') + local f1 = [[ +!A +!B +!C + ]] + local f2 = [[ +?A +?Z +?B +?C +?A +?B +?C +?C + ]] + write_file(fname, f1, false) + write_file(fname_2, f2, false) + reread() + end) + + it('display results', function() + screen:expect([[ + {1: }{10: 1 }{4:^?A }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 2 }{4:?Z }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 3 }{4:?B }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 4 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 5 }{8:?}{9:A }│{1: }{10: 1 }{8:!}{9:A }| + {1: }{10: 6 }{8:?}{9:B }│{1: }{10: 2 }{8:!}{9:B }| + {1: }{10: 7 }{8:?}{9:C }│{1: }{10: 3 }{8:!}{9:C }| + {1: }{10: 8 }{4:?C }│{1: }{10: }{2:--------------------------------------------}| + {1: }{10: 9 } │{1: }{10: 4 } | + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {6:~ }│{6:~ }| + {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| + :e | + ]]) + end) + end) describe('setup a diff with 2 files and set linematch:10', function() before_each(function() feed(':set diffopt+=linematch:10<cr>') @@ -992,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) |