aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/linematch_spec.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:18 +0100
committerJustin M. Keyes <justinkz@gmail.com>2024-01-03 02:09:29 +0100
commit04f2f864e270e772c6326cefdf24947f0130e492 (patch)
tree46f83f909b888a66c741032ab955afc6eab84292 /test/functional/ui/linematch_spec.lua
parent59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff)
downloadrneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2
rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip
refactor: format test/*
Diffstat (limited to 'test/functional/ui/linematch_spec.lua')
-rw-r--r--test/functional/ui/linematch_spec.lua196
1 files changed, 105 insertions, 91 deletions
diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua
index 2dcc8c5858..ca02fa6403 100644
--- a/test/functional/ui/linematch_spec.lua
+++ b/test/functional/ui/linematch_spec.lua
@@ -39,32 +39,33 @@ describe('Diff mode screen with 3 diffs open', function()
screen = Screen.new(100, 16)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
- [6] = {foreground = Screen.colors.Blue1, bold = true};
- [7] = {reverse = true, bold = true};
- [8] = {background = Screen.colors.Red1, bold = true};
- [10] = {foreground = Screen.colors.Brown};
- [9] = {background = Screen.colors.Plum1};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray },
+ [6] = { foreground = Screen.colors.Blue1, bold = true },
+ [7] = { reverse = true, bold = true },
+ [8] = { background = Screen.colors.Red1, bold = true },
+ [10] = { foreground = Screen.colors.Brown },
+ [9] = { background = Screen.colors.Plum1 },
})
feed('<c-w>=')
feed(':windo set nu!<cr>')
end)
- describe('setup the diff screen to look like a merge conflict with 3 files in diff mode', function()
- before_each(function()
-
- local f1 = [[
+ describe(
+ 'setup the diff screen to look like a merge conflict with 3 files in diff mode',
+ function()
+ before_each(function()
+ local f1 = [[
common line
AAA
AAA
AAA
]]
- local f2 = [[
+ local f2 = [[
common line
<<<<<<< HEAD
@@ -77,7 +78,7 @@ describe('Diff mode screen with 3 diffs open', function()
BBB
>>>>>>> branch1
]]
- local f3 = [[
+ local f3 = [[
common line
BBB
@@ -85,16 +86,16 @@ describe('Diff mode screen with 3 diffs open', function()
BBB
]]
- write_file(fname, f1, false)
- write_file(fname_2, f2, false)
- write_file(fname_3, f3, false)
- reread()
- end)
+ write_file(fname, f1, false)
+ write_file(fname_2, f2, false)
+ write_file(fname_3, f3, false)
+ reread()
+ end)
- it('get from window 1', function()
- feed('1<c-w>w')
- feed(':2,6diffget screen-1.2<cr>')
- screen:expect([[
+ it('get from window 1', function()
+ feed('1<c-w>w')
+ feed(':2,6diffget screen-1.2<cr>')
+ screen:expect([[
{1: }{10: 1 }^ │{1: }{10: 1 } │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: 3 }{9:<<<<<<< HEAD }│{1: }{10: 3 }{9:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -111,12 +112,12 @@ describe('Diff mode screen with 3 diffs open', function()
{7:<-functional-diff-screen-1.3 [+] }{3:<est-functional-diff-screen-1.2 Xtest-functional-diff-screen-1 }|
:2,6diffget screen-1.2 |
]])
- end)
+ end)
- it('get from window 2', function()
- feed('2<c-w>w')
- feed(':5,7diffget screen-1.3<cr>')
- screen:expect([[
+ it('get from window 2', function()
+ feed('2<c-w>w')
+ feed(':5,7diffget screen-1.3<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -130,12 +131,12 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<functional-diff-screen-1.2 [+] }{3:Xtest-functional-diff-screen-1 }|
:5,7diffget screen-1.3 |
]])
- end)
+ end)
- it('get from window 3', function()
- feed('3<c-w>w')
- feed(':5,6diffget screen-1.2<cr>')
- screen:expect([[
+ it('get from window 3', function()
+ feed('3<c-w>w')
+ feed(':5,6diffget screen-1.2<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 } │{1: }{10: 1 }^ |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -152,12 +153,12 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 <est-functional-diff-screen-1.2 }{7:<st-functional-diff-screen-1 [+] }|
:5,6diffget screen-1.2 |
]])
- end)
+ end)
- it('put from window 2 - part', function()
- feed('2<c-w>w')
- feed(':6,8diffput screen-1<cr>')
- screen:expect([[
+ it('put from window 2 - part', function()
+ feed('2<c-w>w')
+ feed(':6,8diffput screen-1<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -174,12 +175,11 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<est-functional-diff-screen-1.2 }{3:<st-functional-diff-screen-1 [+] }|
:6,8diffput screen-1 |
]])
-
- end)
- it('put from window 2 - part to end', function()
- feed('2<c-w>w')
- feed(':6,11diffput screen-1<cr>')
- screen:expect([[
+ end)
+ it('put from window 2 - part to end', function()
+ feed('2<c-w>w')
+ feed(':6,11diffput screen-1<cr>')
+ screen:expect([[
{1: }{10: 1 } │{1: }{10: 1 }^ │{1: }{10: 1 } |
{1: }{10: 2 }common line │{1: }{10: 2 }common line │{1: }{10: 2 }common line |
{1: }{10: }{2:---------------------------}│{1: }{10: 3 }{4:<<<<<<< HEAD }│{1: }{10: }{2:---------------------------}|
@@ -196,9 +196,9 @@ describe('Diff mode screen with 3 diffs open', function()
{3:<test-functional-diff-screen-1.3 }{7:<est-functional-diff-screen-1.2 }{3:<st-functional-diff-screen-1 [+] }|
:6,11diffput screen-1 |
]])
-
- end)
- end)
+ end)
+ end
+ )
end)
describe('Diff mode screen with 2 diffs open', function()
@@ -230,16 +230,16 @@ describe('Diff mode screen with 2 diffs open', function()
screen = Screen.new(100, 20)
screen:attach()
screen:set_default_attr_ids({
- [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray};
- [2] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1};
- [3] = {reverse = true};
- [4] = {background = Screen.colors.LightBlue};
- [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray};
- [6] = {foreground = Screen.colors.Blue1, bold = true};
- [7] = {reverse = true, bold = true};
- [8] = {background = Screen.colors.Red1, bold = true};
- [10] = {foreground = Screen.colors.Brown};
- [9] = {background = Screen.colors.Plum1};
+ [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray },
+ [2] = { foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.LightCyan1 },
+ [3] = { reverse = true },
+ [4] = { background = Screen.colors.LightBlue },
+ [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray },
+ [6] = { foreground = Screen.colors.Blue1, bold = true },
+ [7] = { reverse = true, bold = true },
+ [8] = { background = Screen.colors.Red1, bold = true },
+ [10] = { foreground = Screen.colors.Brown },
+ [9] = { background = Screen.colors.Plum1 },
})
feed('<c-w>=')
feed(':windo set nu!<cr>')
@@ -352,7 +352,6 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:4,17diffget |
]])
-
end)
it('get all from window 1', function()
feed('1<c-w>w')
@@ -757,7 +756,6 @@ something
{3:Xtest-functional-diff-screen-1.2 [+] }{7:Xtest-functional-diff-screen-1 }|
:e |
]])
-
end)
end)
describe('setup a diff with 2 files and set linematch:30', function()
@@ -949,10 +947,12 @@ something
reread()
end)
- it('enable linematch for the longest diff block by increasing the number argument passed to linematch', function()
- feed('1<c-w>w')
- -- linematch is disabled for the longest diff because it's combined line length is over 10
- screen:expect([[
+ it(
+ 'enable linematch for the longest diff block by increasing the number argument passed to linematch',
+ function()
+ feed('1<c-w>w')
+ -- linematch is disabled for the longest diff because it's combined line length is over 10
+ screen:expect([[
{1: }{10: 1 }^common line │{1: }{10: 1 }common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -974,10 +974,10 @@ something
{7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }|
:e |
]])
- -- enable it by increasing the number
- feed(":set diffopt-=linematch:10<cr>")
- feed(":set diffopt+=linematch:30<cr>")
- screen:expect([[
+ -- enable it by increasing the number
+ feed(':set diffopt-=linematch:10<cr>')
+ feed(':set diffopt+=linematch:30<cr>')
+ screen:expect([[
{1: }{10: 1 }^common line │{1: }{10: 1 }common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -999,7 +999,8 @@ something
{7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }|
:set diffopt+=linematch:30 |
]])
- end)
+ end
+ )
it('get all from second window', function()
feed('2<c-w>w')
feed(':1,12diffget<cr>')
@@ -1047,10 +1048,12 @@ something
:1,19diffget |
]])
end)
- it('get part of the non linematched diff block in window 2 line 7 - 8 (non line matched block)', function()
- feed('2<c-w>w')
- feed(':7,8diffget<cr>')
- screen:expect([[
+ it(
+ 'get part of the non linematched diff block in window 2 line 7 - 8 (non line matched block)',
+ function()
+ feed('2<c-w>w')
+ feed(':7,8diffget<cr>')
+ screen:expect([[
{1: }{10: 1 }common line │{1: }{10: 1 }^common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -1072,11 +1075,14 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:7,8diffget |
]])
- end)
- it('get part of the non linematched diff block in window 2 line 8 - 10 (line matched block)', function()
- feed('2<c-w>w')
- feed(':8,10diffget<cr>')
- screen:expect([[
+ end
+ )
+ it(
+ 'get part of the non linematched diff block in window 2 line 8 - 10 (line matched block)',
+ function()
+ feed('2<c-w>w')
+ feed(':8,10diffget<cr>')
+ screen:expect([[
{1: }{10: 1 }common line │{1: }{10: 1 }^common line |
{1: }{10: 2 }{4:DEF }│{1: }{10: }{2:--------------------------------------------}|
{1: }{10: 3 }{8:GHI}{9: }│{1: }{10: 2 }{8:HIL}{9: }|
@@ -1098,7 +1104,8 @@ something
{3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }|
:8,10diffget |
]])
- end)
+ end
+ )
end)
end)
@@ -1111,13 +1118,13 @@ describe('regressions', function()
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.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.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()
+ it('properly computes filler lines for hunks bigger than linematch limit', function()
clear()
feed(':set diffopt+=linematch:10<cr>')
screen = Screen.new(100, 20)
@@ -1131,7 +1138,8 @@ describe('regressions', function()
helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' })
helpers.exec 'windo diffthis'
feed('<C-e>')
- screen:expect{grid=[[
+ screen:expect {
+ grid = [[
{1: }{2:------------------------------------------------}│{1: }{3:^1 }|
{1: }{2:------------------------------------------------}│{1: }{3:2 }|
{1: }{2:------------------------------------------------}│{1: }{3:3 }|
@@ -1152,12 +1160,18 @@ describe('regressions', function()
{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};
- }}
+ ]],
+ 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)