diff options
Diffstat (limited to 'test/functional/ui')
36 files changed, 14343 insertions, 19152 deletions
diff --git a/test/functional/ui/bufhl_spec.lua b/test/functional/ui/bufhl_spec.lua index 81e514c9aa..896f75a681 100644 --- a/test/functional/ui/bufhl_spec.lua +++ b/test/functional/ui/bufhl_spec.lua @@ -3,9 +3,10 @@ local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local command, neq = helpers.command, helpers.neq -local meths = helpers.meths -local curbufmeths, eq = helpers.curbufmeths, helpers.eq +local api = helpers.api +local eq = helpers.eq local pcall_err = helpers.pcall_err +local set_virtual_text = api.nvim_buf_set_virtual_text describe('Buffer highlighting', function() local screen @@ -16,31 +17,31 @@ describe('Buffer highlighting', function() screen = Screen.new(40, 8) screen:attach() screen:set_default_attr_ids({ - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {foreground = Screen.colors.Fuchsia}, -- String - [3] = {foreground = Screen.colors.Brown, bold = true}, -- Statement - [4] = {foreground = Screen.colors.SlateBlue}, -- Special - [5] = {bold = true, foreground = Screen.colors.SlateBlue}, - [6] = {foreground = Screen.colors.DarkCyan}, -- Identifier - [7] = {bold = true}, - [8] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue}, - [9] = {foreground = Screen.colors.SlateBlue, underline = true}, - [10] = {foreground = Screen.colors.Red}, - [11] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [12] = {foreground = Screen.colors.Blue1}, - [13] = {background = Screen.colors.LightGrey}, - [14] = {background = Screen.colors.Gray90}, - [15] = {background = Screen.colors.Gray90, bold = true, foreground = Screen.colors.Brown}, - [16] = {foreground = Screen.colors.Magenta, background = Screen.colors.Gray90}, - [17] = {foreground = Screen.colors.Magenta, background = Screen.colors.LightRed}, - [18] = {background = Screen.colors.LightRed}, - [19] = {foreground = Screen.colors.Blue1, background = Screen.colors.LightRed}, - [20] = {underline = true, bold = true, foreground = Screen.colors.Cyan4}, + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { foreground = Screen.colors.Fuchsia }, -- String + [3] = { foreground = Screen.colors.Brown, bold = true }, -- Statement + [4] = { foreground = Screen.colors.SlateBlue }, -- Special + [5] = { bold = true, foreground = Screen.colors.SlateBlue }, + [6] = { foreground = Screen.colors.DarkCyan }, -- Identifier + [7] = { bold = true }, + [8] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue }, + [9] = { foreground = Screen.colors.SlateBlue, underline = true }, + [10] = { foreground = Screen.colors.Red }, + [11] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [12] = { foreground = Screen.colors.Blue1 }, + [13] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [14] = { background = Screen.colors.Gray90 }, + [15] = { background = Screen.colors.Gray90, bold = true, foreground = Screen.colors.Brown }, + [16] = { foreground = Screen.colors.Magenta, background = Screen.colors.Gray90 }, + [17] = { foreground = Screen.colors.Magenta, background = Screen.colors.LightRed }, + [18] = { background = Screen.colors.LightRed }, + [19] = { foreground = Screen.colors.Blue1, background = Screen.colors.LightRed }, + [20] = { underline = true, bold = true, foreground = Screen.colors.Cyan4 }, }) end) - local add_highlight = curbufmeths.add_highlight - local clear_namespace = curbufmeths.clear_namespace + local add_highlight = api.nvim_buf_add_highlight + local clear_namespace = api.nvim_buf_clear_namespace it('works', function() insert([[ @@ -51,49 +52,35 @@ describe('Buffer highlighting', function() screen:expect([[ these are some lines | with colorful tex^t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) - add_highlight(-1, "String", 0 , 10, 14) - add_highlight(-1, "Statement", 1 , 5, -1) + add_highlight(0, -1, 'String', 0, 10, 14) + add_highlight(0, -1, 'Statement', 1, 5, -1) screen:expect([[ these are {2:some} lines | with {3:colorful tex^t} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) - feed("ggo<esc>") + feed('ggo<esc>') screen:expect([[ these are {2:some} lines | ^ | with {3:colorful text} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) - clear_namespace(-1, 0, -1) + clear_namespace(0, -1, 0, -1) screen:expect([[ these are some lines | ^ | with colorful text | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end) @@ -107,89 +94,79 @@ describe('Buffer highlighting', function() combining highlights from different sources]]) - command("hi ImportantWord gui=bold cterm=bold") - id1 = add_highlight(0, "ImportantWord", 0, 2, 8) - add_highlight(id1, "ImportantWord", 1, 12, -1) - add_highlight(id1, "ImportantWord", 2, 0, 9) - add_highlight(id1, "ImportantWord", 3, 5, 14) + command('hi ImportantWord gui=bold cterm=bold') + id1 = add_highlight(0, 0, 'ImportantWord', 0, 2, 8) + add_highlight(0, id1, 'ImportantWord', 1, 12, -1) + add_highlight(0, id1, 'ImportantWord', 2, 0, 9) + add_highlight(0, id1, 'ImportantWord', 3, 5, 14) -- add_highlight can be called like this to get a new source -- without adding any highlight - id2 = add_highlight(0, "", 0, 0, 0) + id2 = add_highlight(0, 0, '', 0, 0, 0) neq(id1, id2) - add_highlight(id2, "Special", 0, 2, 8) - add_highlight(id2, "Identifier", 1, 3, 8) - add_highlight(id2, "Special", 1, 14, 20) - add_highlight(id2, "Underlined", 2, 6, 12) - add_highlight(id2, "Underlined", 3, 0, 9) + add_highlight(0, id2, 'Special', 0, 2, 8) + add_highlight(0, id2, 'Identifier', 1, 3, 8) + add_highlight(0, id2, 'Special', 1, 14, 20) + add_highlight(0, id2, 'Underlined', 2, 6, 12) + add_highlight(0, id2, 'Underlined', 3, 0, 9) screen:expect([[ a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} source^s | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) it('and clearing the first added', function() - clear_namespace(id1, 0, -1) + clear_namespace(0, id1, 0, -1) screen:expect([[ a {4:longer} example | in {6:order} to de{4:monstr}ate | combin{9:ing hi}ghlights | {9:from diff}erent source^s | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) it('and clearing using deprecated name', function() - curbufmeths.clear_highlight(id1, 0, -1) + api.nvim_buf_clear_highlight(0, id1, 0, -1) screen:expect([[ a {4:longer} example | in {6:order} to de{4:monstr}ate | combin{9:ing hi}ghlights | {9:from diff}erent source^s | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) it('and clearing the second added', function() - clear_namespace(id2, 0, -1) + clear_namespace(0, id2, 0, -1) screen:expect([[ a {7:longer} example | in order to {7:demonstrate} | {7:combining} highlights | from {7:different} source^s | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) it('and clearing line ranges', function() - clear_namespace(-1, 0, 1) - clear_namespace(id1, 1, 2) - clear_namespace(id2, 2, -1) + clear_namespace(0, -1, 0, 1) + clear_namespace(0, id1, 1, 2) + clear_namespace(0, id2, 2, -1) screen:expect([[ a longer example | in {6:order} to de{4:monstr}ate | {7:combining} highlights | from {7:different} source^s | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) @@ -201,9 +178,7 @@ describe('Buffer highlighting', function() ^ | in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) @@ -211,231 +186,229 @@ describe('Buffer highlighting', function() -- the deleted line wrapping around. we should invalidate -- highlights when they are completely inside deleted text command('3move 4') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | | {8:from different sources} | {8:^in }{20:order}{8: to demonstrate} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } --screen:expect([[ -- a {5:longer} example | -- | -- {9:from }{8:diff}{7:erent} sources | -- ^in {6:order} to {7:de}{5:monstr}{7:ate} | - -- {1:~ }| - -- {1:~ }| - -- {1:~ }| + -- {1:~ }|*3 -- | --]]) command('undo') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | ^ | in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 change; before #4 {MATCH:.*}| - ]]} + ]], + } command('undo') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 1 line less; before #3 {MATCH:.*}| - ]]} + ]], + } command('undo') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {7:^combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 more line; before #2 {MATCH:.*}| - ]]} + ]], + } end) it('and moving lines around', function() command('2move 3') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | {7:combin}{8:ing}{9: hi}ghlights | ^in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } command('1,2move 4') - screen:expect{grid=[[ + screen:expect { + grid = [[ in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | a {5:longer} example | {7:^combin}{8:ing}{9: hi}ghlights | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } command('undo') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | {7:combin}{8:ing}{9: hi}ghlights | ^in {6:order} to {7:de}{5:monstr}{7:ate} | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 2 changes; before #3 {MATCH:.*}| - ]]} + ]], + } command('undo') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | ^in {6:order} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 change; before #2 {MATCH:.*}| - ]]} + ]], + } end) it('and adjusting columns', function() -- insert before feed('ggiquite <esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ quite^ a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 change; before #2 {MATCH:.*}| - ]]} + ]], + } -- change/insert in the middle feed('+fesAAAA') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:ordAAAA^r} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {7:-- INSERT --} | - ]]} + ]], + } feed('<esc>tdD') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:ordAAAAr} t^o | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:ordAAAAr} to^ {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 change; before #4 {MATCH:.*}| - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:ord^er} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 change; before #3 {MATCH:.*}| - ]]} + ]], + } end) it('and joining lines', function() feed('ggJJJ') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example in {6:order} to {7:de}{5:monstr}{7:ate}| {7:combin}{8:ing}{9: hi}ghlights^ {9:from }{8:diff}{7:erent} sou| rces | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } feed('uuu') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^a {5:longer} example | in {6:order} to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 more line; before #2 {MATCH:.*}| - ]]} + ]], + } end) it('and splitting lines', function() feed('2Gtti<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:order} | ^ to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| + {1:~ }|*2 {7:-- INSERT --} | - ]]} + ]], + } feed('<esc>tsi<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:order} | to {7:de}{5:mo} | @@ -444,61 +417,53 @@ describe('Buffer highlighting', function() {9:from }{8:diff}{7:erent} sources | {1:~ }| {7:-- INSERT --} | - ]]} + ]], + } feed('<esc>u') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:order} | to {7:de}{5:mo^nstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| + {1:~ }|*2 1 line less; before #3 {MATCH:.*}| - ]]} + ]], + } feed('<esc>u') - screen:expect{grid=[[ + screen:expect { + grid = [[ a {5:longer} example | in {6:order}^ to {7:de}{5:monstr}{7:ate} | {7:combin}{8:ing}{9: hi}ghlights | {9:from }{8:diff}{7:erent} sources | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 1 line less; before #2 {MATCH:.*}| - ]]} + ]], + } end) end) pending('prioritizes latest added highlight', function() insert([[ three overlapping colors]]) - add_highlight(0, "Identifier", 0, 6, 17) - add_highlight(0, "String", 0, 14, 23) - local id = add_highlight(0, "Special", 0, 0, 9) + add_highlight(0, 0, 'Identifier', 0, 6, 17) + add_highlight(0, 0, 'String', 0, 14, 23) + local id = add_highlight(0, 0, 'Special', 0, 0, 9) screen:expect([[ {4:three ove}{6:rlapp}{2:ing color}^s | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) - clear_namespace(id, 0, 1) + clear_namespace(0, id, 0, 1) screen:expect([[ three {6:overlapp}{2:ing color}^s | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) @@ -506,96 +471,76 @@ describe('Buffer highlighting', function() it('prioritizes earlier highlight groups (TEMP)', function() insert([[ three overlapping colors]]) - add_highlight(0, "Identifier", 0, 6, 17) - add_highlight(0, "String", 0, 14, 23) - local id = add_highlight(0, "Special", 0, 0, 9) + add_highlight(0, 0, 'Identifier', 0, 6, 17) + add_highlight(0, 0, 'String', 0, 14, 23) + local id = add_highlight(0, 0, 'Special', 0, 0, 9) - screen:expect{grid=[[ + screen:expect { + grid = [[ {4:three }{6:overlapp}{2:ing color}^s | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | - ]]} + ]], + } - clear_namespace(id, 0, 1) - screen:expect{grid=[[ + clear_namespace(0, id, 0, 1) + screen:expect { + grid = [[ three {6:overlapp}{2:ing color}^s | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | - ]]} + ]], + } end) it('respects priority', function() - local set_extmark = curbufmeths.set_extmark - local id = meths.create_namespace('') + local id = api.nvim_create_namespace('') insert [[foobar]] - set_extmark(id, 0, 0, { + api.nvim_buf_set_extmark(0, id, 0, 0, { end_line = 0, end_col = 5, - hl_group = "Statement", - priority = 100 + hl_group = 'Statement', + priority = 100, }) - set_extmark(id, 0, 0, { + api.nvim_buf_set_extmark(0, id, 0, 0, { end_line = 0, end_col = 6, - hl_group = "String", - priority = 1 + hl_group = 'String', + priority = 1, }) screen:expect [[ {3:fooba}{2:^r} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]] - clear_namespace(id, 0, -1) - screen:expect{grid=[[ + clear_namespace(0, id, 0, -1) + screen:expect { + grid = [[ fooba^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | - ]]} + ]], + } - set_extmark(id, 0, 0, { + api.nvim_buf_set_extmark(0, id, 0, 0, { end_line = 0, end_col = 6, - hl_group = "String", - priority = 1 + hl_group = 'String', + priority = 1, }) - set_extmark(id, 0, 0, { + api.nvim_buf_set_extmark(0, id, 0, 0, { end_line = 0, end_col = 5, - hl_group = "Statement", - priority = 100 + hl_group = 'Statement', + priority = 100, }) screen:expect [[ {3:fooba}{2:^r} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]] end) @@ -603,17 +548,12 @@ describe('Buffer highlighting', function() it('works with multibyte text', function() insert([[ Ta båten över sjön!]]) - add_highlight(-1, "Identifier", 0, 3, 9) - add_highlight(-1, "String", 0, 16, 21) + add_highlight(0, -1, 'Identifier', 0, 3, 9) + add_highlight(0, -1, 'String', 0, 16, 21) screen:expect([[ Ta {6:båten} över {2:sjön}^! | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) @@ -621,33 +561,22 @@ describe('Buffer highlighting', function() it('works with new syntax groups', function() insert([[ fancy code in a new fancy language]]) - add_highlight(-1, "FancyLangItem", 0, 0, 5) + add_highlight(0, -1, 'FancyLangItem', 0, 0, 5) screen:expect([[ fancy code in a new fancy languag^e | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) command('hi FancyLangItem guifg=red') screen:expect([[ {10:fancy} code in a new fancy languag^e | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) describe('virtual text decorations', function() - local set_virtual_text = curbufmeths.set_virtual_text local id1, id2 before_each(function() insert([[ @@ -661,16 +590,18 @@ describe('Buffer highlighting', function() 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, | x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - id1 = set_virtual_text(0, 0, {{"=", "Statement"}, {" 3", "Number"}}, {}) - set_virtual_text(id1, 1, {{"ERROR:", "ErrorMsg"}, {" invalid syntax"}}, {}) - id2 = set_virtual_text(0, 2, {{"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}}, {}) + id1 = set_virtual_text(0, 0, 0, { { '=', 'Statement' }, { ' 3', 'Number' } }, {}) + set_virtual_text(0, id1, 1, { { 'ERROR:', 'ErrorMsg' }, { ' invalid syntax' } }, {}) + id2 = set_virtual_text(0, 0, 2, { + { + 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', + }, + }, {}) neq(id2, id1) - end) it('works', function() @@ -680,278 +611,298 @@ describe('Buffer highlighting', function() 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - clear_namespace(id1, 0, -1) + clear_namespace(0, id1, 0, -1) screen:expect([[ ^1 + 2 | 3 + | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) -- Handles doublewidth chars, leaving a space if truncating -- in the middle of a char - eq(-1, set_virtual_text(-1, 1, {{"暗x事zz速野谷質結育副住新覚丸活解終事", "Comment"}}, {})) + eq( + -1, + set_virtual_text( + 0, + -1, + 1, + { { '暗x事zz速野谷質結育副住新覚丸活解終事', 'Comment' } }, + {} + ) + ) screen:expect([[ ^1 + 2 | 3 + {12:暗x事zz速野谷質結育副住新覚丸活解終 }| 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - feed("2Gx") + feed('2Gx') screen:expect([[ 1 + 2 | ^ + {12:暗x事zz速野谷質結育副住新覚丸活解終事}| 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - feed("2Gdd") + feed('2Gdd') -- TODO(bfredl): currently decorations get moved from a deleted line -- to the next one. We might want to add "invalidation" when deleting -- over a decoration. - screen:expect{grid=[[ + screen:expect { + grid = [[ 1 + 2 | ^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, {12:暗x事zz速野谷質結育}| x = 4 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } --screen:expect([[ -- 1 + 2 | -- ^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| -- , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| -- x = 4 | - -- {1:~ }| - -- {1:~ }| - -- {1:~ }| + -- {1:~ }|*3 -- | --]]) end) it('validates contents', function() -- this used to leak memory - eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {"texty"}, {})) - eq("Invalid 'chunk': expected Array, got String", pcall_err(set_virtual_text, id1, 0, {{"very"}, "texty"}, {})) + eq( + "Invalid 'chunk': expected Array, got String", + pcall_err(set_virtual_text, 0, id1, 0, { 'texty' }, {}) + ) + eq( + "Invalid 'chunk': expected Array, got String", + pcall_err(set_virtual_text, 0, id1, 0, { { 'very' }, 'texty' }, {}) + ) end) it('can be retrieved', function() - local get_extmarks = curbufmeths.get_extmarks - local line_count = curbufmeths.line_count - - local s1 = {{'Köttbullar', 'Comment'}, {'Kräuterbutter'}} - local s2 = {{'こんにちは', 'Comment'}} - - set_virtual_text(id1, 0, s1, {}) - eq({{1, 0, 0, { - ns_id = 1, - priority = 0, - virt_text = s1, - -- other details - right_gravity = true, - virt_text_pos = 'eol', - virt_text_hide = false, - }}}, get_extmarks(id1, {0,0}, {0, -1}, {details=true})) - - local lastline = line_count() - set_virtual_text(id1, line_count(), s2, {}) - eq({{3, lastline, 0, { - ns_id = 1, - priority = 0, - virt_text = s2, - -- other details - right_gravity = true, - virt_text_pos = 'eol', - virt_text_hide = false, - }}}, get_extmarks(id1, {lastline,0}, {lastline, -1}, {details=true})) - - eq({}, get_extmarks(id1, {lastline+9000,0}, {lastline+9000, -1}, {})) + local get_extmarks = api.nvim_buf_get_extmarks + local line_count = api.nvim_buf_line_count + + local s1 = { { 'Köttbullar', 'Comment' }, { 'Kräuterbutter' } } + local s2 = { { 'こんにちは', 'Comment' } } + + set_virtual_text(0, id1, 0, s1, {}) + eq({ + { + 1, + 0, + 0, + { + ns_id = 1, + priority = 0, + virt_text = s1, + -- other details + right_gravity = true, + virt_text_repeat_linebreak = false, + virt_text_pos = 'eol', + virt_text_hide = false, + }, + }, + }, get_extmarks(0, id1, { 0, 0 }, { 0, -1 }, { details = true })) + + local lastline = line_count(0) + set_virtual_text(0, id1, line_count(0), s2, {}) + eq({ + { + 3, + lastline, + 0, + { + ns_id = 1, + priority = 0, + virt_text = s2, + -- other details + right_gravity = true, + virt_text_repeat_linebreak = false, + virt_text_pos = 'eol', + virt_text_hide = false, + }, + }, + }, get_extmarks(0, id1, { lastline, 0 }, { lastline, -1 }, { details = true })) + + eq({}, get_extmarks(0, id1, { lastline + 9000, 0 }, { lastline + 9000, -1 }, {})) end) it('is not highlighted by visual selection', function() - feed("ggVG") + feed('ggVG') screen:expect([[ {13:1 + 2} {3:=}{2: 3} | {13:3 +} {11:ERROR:} invalid syntax | {13:5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}| {13:, 5, 5, 5, 5, 5, 5, } Lorem ipsum dolor s| ^x{13: = 4} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {7:-- VISUAL LINE --} | ]]) - feed("<esc>") + feed('<esc>') screen:expect([[ 1 + 2 {3:=}{2: 3} | 3 + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| ^x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) -- special case: empty line has extra eol highlight - feed("ggd$") + feed('ggd$') screen:expect([[ ^ {3:=}{2: 3} | 3 + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - feed("jvk") + feed('jvk') screen:expect([[ ^ {3:=}{2: 3} | {13:3} + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 {7:-- VISUAL --} | ]]) - feed("o") + feed('o') screen:expect([[ {13: }{3:=}{2: 3} | ^3 + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 {7:-- VISUAL --} | ]]) end) - it('works with listchars', function() - command("set list listchars+=eol:$") + command('set list listchars+=eol:$') screen:expect([[ ^1 + 2{1:$}{3:=}{2: 3} | 3 +{1:$}{11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5,{1:-$}Lorem ipsum dolor s| x = 4{1:$} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - clear_namespace(-1, 0, -1) + clear_namespace(0, -1, 0, -1) screen:expect([[ ^1 + 2{1:$} | 3 +{1:$} | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5,{1:-$} | x = 4{1:$} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end) it('works with cursorline', function() - command("set cursorline") + command('set cursorline') - screen:expect{grid=[[ + screen:expect { + grid = [[ {14:^1 + 2 }{3:=}{2: 3}{14: }| 3 + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ 1 + 2 {3:=}{2: 3} | {14:^3 + }{11:ERROR:} invalid syntax{14: }| 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | - ]]} - + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ 1 + 2 {3:=}{2: 3} | 3 + {11:ERROR:} invalid syntax | {14:^5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}| {14:, 5, 5, 5, 5, 5, 5, }Lorem ipsum dolor s| x = 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | - ]]} + ]], + } end) it('works with color column', function() - eq(-1, set_virtual_text(-1, 3, {{"暗x事", "Comment"}}, {})) - screen:expect{grid=[[ + eq(-1, set_virtual_text(0, -1, 3, { { '暗x事', 'Comment' } }, {})) + screen:expect { + grid = [[ ^1 + 2 {3:=}{2: 3} | 3 + {11:ERROR:} invalid syntax | 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 {12:暗x事} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | - ]]} + ]], + } - command("set colorcolumn=9") - screen:expect{grid=[[ + command('set colorcolumn=9') + screen:expect { + grid = [[ ^1 + 2 {3:=}{2: 3} | 3 + {11:ERROR:} invalid syntax | 5, 5, 5,{18: }5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5| , 5, 5, 5, 5, 5, 5, Lorem ipsum dolor s| x = 4 {12:暗x事} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | - ]]} + ]], + } end) end) it('and virtual text use the same namespace counter', function() - local set_virtual_text = curbufmeths.set_virtual_text - eq(1, add_highlight(0, "String", 0 , 0, -1)) - eq(2, set_virtual_text(0, 0, {{"= text", "Comment"}}, {})) - eq(3, meths.create_namespace("my-ns")) - eq(4, add_highlight(0, "String", 0 , 0, -1)) - eq(5, set_virtual_text(0, 0, {{"= text", "Comment"}}, {})) - eq(6, meths.create_namespace("other-ns")) + eq(1, add_highlight(0, 0, 'String', 0, 0, -1)) + eq(2, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) + eq(3, api.nvim_create_namespace('my-ns')) + eq(4, add_highlight(0, 0, 'String', 0, 0, -1)) + eq(5, set_virtual_text(0, 0, 0, { { '= text', 'Comment' } }, {})) + eq(6, api.nvim_create_namespace('other-ns')) end) end) diff --git a/test/functional/ui/cmdline_highlight_spec.lua b/test/functional/ui/cmdline_highlight_spec.lua index e4766103c2..6c4000ba41 100644 --- a/test/functional/ui/cmdline_highlight_spec.lua +++ b/test/functional/ui/cmdline_highlight_spec.lua @@ -4,13 +4,12 @@ local Screen = require('test.functional.ui.screen') local eq = helpers.eq local feed = helpers.feed local clear = helpers.clear -local meths = helpers.meths -local funcs = helpers.funcs +local api = helpers.api +local fn = helpers.fn local source = helpers.source local exec_capture = helpers.exec_capture local dedent = helpers.dedent local command = helpers.command -local curbufmeths = helpers.curbufmeths local screen @@ -138,36 +137,35 @@ before_each(function() endfunction ]]) screen:set_default_attr_ids({ - RBP1={background = Screen.colors.Red}, - RBP2={background = Screen.colors.Yellow}, - RBP3={background = Screen.colors.Green}, - RBP4={background = Screen.colors.Blue}, - EOB={bold = true, foreground = Screen.colors.Blue1}, - ERR={foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - SK={foreground = Screen.colors.Blue}, - PE={bold = true, foreground = Screen.colors.SeaGreen4}, - NUM={foreground = Screen.colors.Blue2}, - NPAR={foreground = Screen.colors.Yellow}, - SQ={foreground = Screen.colors.Blue3}, - SB={foreground = Screen.colors.Blue4}, - E={foreground = Screen.colors.Red, background = Screen.colors.Blue}, - M={bold = true}, - MSEP={bold = true, reverse = true}; + RBP1 = { background = Screen.colors.Red }, + RBP2 = { background = Screen.colors.Yellow }, + RBP3 = { background = Screen.colors.Green }, + RBP4 = { background = Screen.colors.Blue }, + EOB = { bold = true, foreground = Screen.colors.Blue1 }, + ERR = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + SK = { foreground = Screen.colors.Blue }, + PE = { bold = true, foreground = Screen.colors.SeaGreen4 }, + NUM = { foreground = Screen.colors.Blue2 }, + NPAR = { foreground = Screen.colors.Yellow }, + SQ = { foreground = Screen.colors.Blue3 }, + SB = { foreground = Screen.colors.Blue4 }, + E = { foreground = Screen.colors.Red, background = Screen.colors.Blue }, + M = { bold = true }, + MSEP = { bold = true, reverse = true }, }) end) local function set_color_cb(funcname, callback_return, id) - meths.set_var('id', id or '') - if id and id ~= '' and funcs.exists('*' .. funcname .. 'N') then - command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format( - id, funcname, id)) + api.nvim_set_var('id', id or '') + if id and id ~= '' and fn.exists('*' .. funcname .. 'N') then + command(('let g:Nvim_color_input%s = {cmdline -> %sN(%s, cmdline)}'):format(id, funcname, id)) if callback_return then - meths.set_var('callback_return' .. id, callback_return) + api.nvim_set_var('callback_return' .. id, callback_return) end else - meths.set_var('Nvim_color_input', funcname) + api.nvim_set_var('Nvim_color_input', funcname) if callback_return then - meths.set_var('callback_return', callback_return) + api.nvim_set_var('callback_return', callback_return) end end end @@ -178,142 +176,94 @@ end describe('Command-line coloring', function() it('works', function() set_color_cb('RainBowParens') - meths.set_option_value('more', false, {}) + api.nvim_set_option_value('more', false, {}) start_prompt() screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :^ | ]]) feed('e') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :e^ | ]]) feed('cho ') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo ^ | ]]) feed('(') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}^ | ]]) feed('(') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}^ | ]]) feed('42') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}42^ | ]]) feed('))') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}42{RBP2:)}{RBP1:)}^ | ]]) feed('<BS>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | ]]) redraw_input() - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}42{RBP2:)}^ | - ]], reset=true} + ]], + reset = true, + } end) - for _, func_part in ipairs({'', 'n', 'msg'}) do + for _, func_part in ipairs({ '', 'n', 'msg' }) do it('disables :echo' .. func_part .. ' messages', function() set_color_cb('Echo' .. func_part .. 'ing') start_prompt('echo') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo^ | ]]) end) end - it('does the right thing when hl start appears to split multibyte char', - function() + it('does the right thing when hl start appears to split multibyte char', function() set_color_cb('SplitMultibyteStart') start_prompt('echo "«') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :echo " | {ERR:E5405: Chunk 0 start 7 splits multibyte }| {ERR:character} | :echo "«^ | - ]]} + ]], + } feed('»') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :echo " | {ERR:E5405: Chunk 0 start 7 splits multibyte }| @@ -321,14 +271,12 @@ describe('Command-line coloring', function() :echo "«»^ | ]]) end) - it('does the right thing when hl end appears to split multibyte char', - function() + it('does the right thing when hl end appears to split multibyte char', function() set_color_cb('SplitMultibyteEnd') start_prompt('echo "«') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :echo " | {ERR:E5406: Chunk 0 end 7 splits multibyte ch}| @@ -355,12 +303,7 @@ describe('Command-line coloring', function() start_prompt('e') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :e^ | ]]) eq('', exec_capture('messages')) @@ -370,12 +313,7 @@ describe('Command-line coloring', function() start_prompt('e') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :e^ | ]]) eq('', exec_capture('messages')) @@ -385,12 +323,7 @@ describe('Command-line coloring', function() start_prompt('e') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :e^ | ]]) eq('', exec_capture('messages')) @@ -414,8 +347,7 @@ describe('Command-line coloring', function() start_prompt('let x = "«»«»«»«»«»"') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :let x = " | {ERR:E5405: Chunk 0 start 10 splits multibyte}| @@ -425,38 +357,27 @@ describe('Command-line coloring', function() feed('\n') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 | ]]) feed('\n') - eq('let x = "«»«»«»«»«»"', meths.get_var('out')) + eq('let x = "«»«»«»«»«»"', api.nvim_get_var('out')) local msg = '\nE5405: Chunk 0 start 10 splits multibyte character' - eq(msg:rep(1), funcs.execute('messages')) + eq(msg:rep(1), fn.execute('messages')) end) it('allows interrupting callback with <C-c>', function() set_color_cb('Halting') start_prompt('echo 42') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 | ]]) screen:sleep(500) feed('<C-c>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| : | {ERR:E5407: Callback has thrown an exception:}| @@ -466,36 +387,21 @@ describe('Command-line coloring', function() redraw_input() screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo 42^ | ]]) feed('\n') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo 42 | ]]) feed('\n') - eq('echo 42', meths.get_var('out')) + eq('echo 42', api.nvim_get_var('out')) feed('<C-c>') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 Type :qa and pre...nter> to exit Nvim | ]]) end) @@ -504,12 +410,7 @@ describe('Command-line coloring', function() start_prompt('echo ("<C-v><CR><C-v><Nul><C-v><NL>")') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}"{SK:^M^@^@}"{RBP1:)}^ | ]]) end) @@ -519,9 +420,7 @@ describe('Command-line coloring', function() start_prompt('#') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*3 {MSEP: }| : | {ERR:E5400: Callback should return list} | @@ -529,13 +428,11 @@ describe('Command-line coloring', function() ]]) feed('<CR><CR><CR>') - set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}, 42}) + set_color_cb('ReturningGlobal', { { 0, 1, 'Normal' }, 42 }) start_prompt('#') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*3 {MSEP: }| : | {ERR:E5401: List item 1 is not a List} | @@ -543,12 +440,11 @@ describe('Command-line coloring', function() ]]) feed('<CR><CR><CR>') - set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1}}) + set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 1 } }) start_prompt('+') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :+ | {ERR:E5402: List item 1 has incorrect length:}| @@ -557,12 +453,11 @@ describe('Command-line coloring', function() ]]) feed('<CR><CR><CR>') - set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {2, 3, 'Normal'}}) + set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 2, 3, 'Normal' } }) start_prompt('+') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :+ | {ERR:E5403: Chunk 1 start 2 not in range [1, }| @@ -571,13 +466,11 @@ describe('Command-line coloring', function() ]]) feed('<CR><CR><CR>') - set_color_cb('ReturningGlobal2', {{0, 1, 'Normal'}, {1, 3, 'Normal'}}) + set_color_cb('ReturningGlobal2', { { 0, 1, 'Normal' }, { 1, 3, 'Normal' } }) start_prompt('+') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*3 {MSEP: }| :+ | {ERR:E5404: Chunk 1 end 3 not in range (1, 2]}| @@ -585,7 +478,7 @@ describe('Command-line coloring', function() ]]) end) it('does not error out when called from a errorred out cycle', function() - set_color_cb('ReturningGlobal', {{0, 1, 'Normal'}}) + set_color_cb('ReturningGlobal', { { 0, 1, 'Normal' } }) feed(dedent([[ :set regexpengine=2 :for pat in [' \ze*', ' \zs*'] @@ -607,117 +500,79 @@ describe('Command-line coloring', function() : : ]])) - eq({'', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*'}, - curbufmeths.get_lines(0, -1, false)) - eq('', funcs.execute('messages')) + eq( + { '', ':', 'E888 detected for \\ze*', ':', 'E888 detected for \\zs*' }, + api.nvim_buf_get_lines(0, 0, -1, false) + ) + eq('', fn.execute('messages')) end) it('allows nesting input()s', function() - set_color_cb('ReturningGlobal', {{0, 1, 'RBP1'}}, '') + set_color_cb('ReturningGlobal', { { 0, 1, 'RBP1' } }, '') start_prompt('1') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP1:1}^ | ]]) - set_color_cb('ReturningGlobal', {{0, 1, 'RBP2'}}, '1') + set_color_cb('ReturningGlobal', { { 0, 1, 'RBP2' } }, '1') start_prompt('2') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP2:2}^ | ]]) - set_color_cb('ReturningGlobal', {{0, 1, 'RBP3'}}, '2') + set_color_cb('ReturningGlobal', { { 0, 1, 'RBP3' } }, '2') start_prompt('3') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP3:3}^ | ]]) - set_color_cb('ReturningGlobal', {{0, 1, 'RBP4'}}, '3') + set_color_cb('ReturningGlobal', { { 0, 1, 'RBP4' } }, '3') start_prompt('4') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP4:4}^ | ]]) feed('<CR>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP3:3}4^ | ]]) feed('<CR>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP2:2}34^ | ]]) feed('<CR>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :{RBP1:1}234^ | ]]) feed('<CR><CR><C-l>') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 | ]]) - eq('1234', meths.get_var('out')) - eq('234', meths.get_var('out1')) - eq('34', meths.get_var('out2')) - eq('4', meths.get_var('out3')) - eq(0, funcs.exists('g:out4')) + eq('1234', api.nvim_get_var('out')) + eq('234', api.nvim_get_var('out1')) + eq('34', api.nvim_get_var('out2')) + eq('4', api.nvim_get_var('out3')) + eq(0, fn.exists('g:out4')) end) it('runs callback with the same data only once', function() local function new_recording_calls(...) - eq({...}, meths.get_var('recording_calls')) - meths.set_var('recording_calls', {}) + eq({ ... }, api.nvim_get_var('recording_calls')) + api.nvim_set_var('recording_calls', {}) end set_color_cb('Recording') start_prompt('') @@ -726,22 +581,21 @@ describe('Command-line coloring', function() -- new_recording_calls(expected_result) -- (actual_before_fix) -- feed('a') - new_recording_calls('a') -- ('a', 'a') + new_recording_calls('a') -- ('a', 'a') feed('b') new_recording_calls('ab') -- ('a', 'ab', 'ab') feed('c') - new_recording_calls('abc') -- ('ab', 'abc', 'abc') + new_recording_calls('abc') -- ('ab', 'abc', 'abc') feed('<BS>') - new_recording_calls('ab') -- ('abc', 'ab', 'ab') + new_recording_calls('ab') -- ('abc', 'ab', 'ab') feed('<BS>') - new_recording_calls('a') -- ('ab', 'a', 'a') + new_recording_calls('a') -- ('ab', 'a', 'a') feed('<BS>') - new_recording_calls() -- ('a') + new_recording_calls() -- ('a') feed('<CR><CR>') - eq('', meths.get_var('out')) + eq('', api.nvim_get_var('out')) end) - it('does not crash when callback has caught not-a-editor-command exception', - function() + it('does not crash when callback has caught not-a-editor-command exception', function() source([[ function CaughtExc(cmdline) abort try @@ -754,30 +608,25 @@ describe('Command-line coloring', function() ]]) set_color_cb('CaughtExc') start_prompt('1') - eq(1, meths.eval('1')) + eq(1, api.nvim_eval('1')) end) end) describe('Ex commands coloring', function() it('works', function() - meths.set_var('Nvim_color_cmdline', 'RainBowParens') + api.nvim_set_var('Nvim_color_cmdline', 'RainBowParens') feed(':echo (((1)))') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :echo {RBP1:(}{RBP2:(}{RBP3:(}1{RBP3:)}{RBP2:)}{RBP1:)}^ | ]]) end) it('still executes command-line even if errored out', function() - meths.set_var('Nvim_color_cmdline', 'SplitMultibyteStart') + api.nvim_set_var('Nvim_color_cmdline', 'SplitMultibyteStart') feed(':let x = "«"\n') - eq('«', meths.get_var('x')) + eq('«', api.nvim_get_var('x')) local msg = 'E5405: Chunk 0 start 10 splits multibyte character' - eq('\n'..msg, funcs.execute('messages')) + eq('\n' .. msg, fn.execute('messages')) end) it('does not error out when called from a errorred out cycle', function() -- Apparently when there is a cycle in which one of the commands errors out @@ -794,16 +643,17 @@ describe('Ex commands coloring', function() : endtry :endfor ]])) - eq({'', 'E888 detected for \\ze*', 'E888 detected for \\zs*'}, - curbufmeths.get_lines(0, -1, false)) - eq('', funcs.execute('messages')) + eq( + { '', 'E888 detected for \\ze*', 'E888 detected for \\zs*' }, + api.nvim_buf_get_lines(0, 0, -1, false) + ) + eq('', fn.execute('messages')) end) it('does not crash when using `n` in debug mode', function() feed(':debug execute "echo 1"\n') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| Entering Debug mode. Type "cont" to con| tinue. | @@ -824,12 +674,7 @@ describe('Ex commands coloring', function() feed('\n') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 | ]]) end) @@ -838,8 +683,7 @@ describe('Ex commands coloring', function() feed(':#x') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*2 {MSEP: }| :# | {ERR:Error detected while processing :} | @@ -858,11 +702,13 @@ describe('Ex commands coloring', function() {PE:Press ENTER or type command to continue}^ | ]]) feed('<CR>') - eq('Error detected while processing :\nE605: Exception not caught: 42\nE749: Empty buffer', - exec_capture('messages')) + eq( + 'Error detected while processing :\nE605: Exception not caught: 42\nE749: Empty buffer', + exec_capture('messages') + ) end) it('errors out when failing to get callback', function() - meths.set_var('Nvim_color_cmdline', 42) + api.nvim_set_var('Nvim_color_cmdline', 42) feed(':#') screen:expect([[ | @@ -878,77 +724,52 @@ describe('Ex commands coloring', function() end) describe('Expressions coloring support', function() it('works', function() - meths.command('hi clear NvimNumber') - meths.command('hi clear NvimNestingParenthesis') - meths.command('hi NvimNumber guifg=Blue2') - meths.command('hi NvimNestingParenthesis guifg=Yellow') + command('hi clear NvimNumber') + command('hi clear NvimNestingParenthesis') + command('hi NvimNumber guifg=Blue2') + command('hi NvimNestingParenthesis guifg=Yellow') feed(':echo <C-r>=(((1)))') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 ={NPAR:(((}{NUM:1}{NPAR:)))}^ | ]]) end) it('does not use Nvim_color_expr', function() - meths.set_var('Nvim_color_expr', 42) + api.nvim_set_var('Nvim_color_expr', 42) -- Used to error out due to failing to get callback. - meths.command('hi clear NvimNumber') - meths.command('hi NvimNumber guifg=Blue2') + command('hi clear NvimNumber') + command('hi NvimNumber guifg=Blue2') feed(':<C-r>=1') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 ={NUM:1}^ | ]]) end) it('works correctly with non-ASCII and control characters', function() - meths.command('hi clear NvimStringBody') - meths.command('hi clear NvimStringQuote') - meths.command('hi clear NvimInvalid') - meths.command('hi NvimStringQuote guifg=Blue3') - meths.command('hi NvimStringBody guifg=Blue4') - meths.command('hi NvimInvalid guifg=Red guibg=Blue') + command('hi clear NvimStringBody') + command('hi clear NvimStringQuote') + command('hi clear NvimInvalid') + command('hi NvimStringQuote guifg=Blue3') + command('hi NvimStringBody guifg=Blue4') + command('hi NvimInvalid guifg=Red guibg=Blue') feed('i<C-r>="«»"«»') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 ={SQ:"}{SB:«»}{SQ:"}{E:«»}^ | ]]) feed('<C-c>') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 {M:-- INSERT --} | ]]) feed('<Esc>') screen:expect([[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 | ]]) feed(':<C-\\>e"<C-v><C-x>"<C-v><C-x>') @@ -956,35 +777,20 @@ describe('Expressions coloring support', function() -- highlighting. screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 ={SQ:"}{SB:^X}{SQ:"}{ERR:^X}^ | ]]) feed('<C-c>') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 :^ | ]]) - funcs.setreg('a', {'\192'}) + fn.setreg('a', { '\192' }) feed('<C-r>="<C-r><C-r>a"<C-r><C-r>a"foo"') screen:expect([[ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*6 ={SQ:"}{SB:<c0>}{SQ:"}{E:<c0>"}{SB:foo}{E:"}^ | ]]) end) diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 188b9ee87b..0eb5770819 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -9,22 +9,22 @@ local exec = helpers.exec local eval = helpers.eval local eq = helpers.eq local is_os = helpers.is_os -local meths = helpers.meths +local api = helpers.api local function new_screen(opt) local screen = Screen.new(25, 5) screen:attach(opt) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {reverse = true}, - [3] = {bold = true, reverse = true}, - [4] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [6] = {foreground = Screen.colors.Magenta}, - [7] = {bold = true, foreground = Screen.colors.Brown}, - [8] = {background = Screen.colors.LightGrey}, - [9] = {bold = true}, - [10] = {background = Screen.colors.Yellow1}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { reverse = true }, + [3] = { bold = true, reverse = true }, + [4] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [6] = { foreground = Screen.colors.Magenta }, + [7] = { bold = true, foreground = Screen.colors.Brown }, + [8] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [9] = { bold = true }, + [10] = { background = Screen.colors.Yellow1 }, }) return screen end @@ -34,370 +34,445 @@ local function test_cmdline(linegrid) before_each(function() clear() - screen = new_screen({rgb=true, ext_cmdline=true, ext_linegrid=linegrid}) + screen = new_screen({ rgb = true, ext_cmdline = true, ext_linegrid = linegrid }) end) it('works', function() feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{""}}, - pos = 0, - }}} + ]], + cmdline = { { + firstc = ':', + content = { { '' } }, + pos = 0, + } }, + } feed('sign') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign' } }, + pos = 4, + }, + }, + } feed('<Left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign"}}, - pos = 3, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign' } }, + pos = 3, + }, + }, + } feed('<bs>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sin"}}, - pos = 2, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sin' } }, + pos = 2, + }, + }, + } feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } end) - it("works with input()", function() + it('works with input()', function() feed(':call input("input", "default")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - prompt = "input", - content = {{"default"}}, - pos = 7, - }}} + ]], + cmdline = { + { + prompt = 'input', + content = { { 'default' } }, + pos = 7, + }, + }, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } end) - it("works with special chars and nested cmdline", function() + it('works with special chars and nested cmdline', function() feed(':xx<c-r>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + }, + } feed('=') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }, { - firstc = "=", - content = {{""}}, - pos = 0, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + { + firstc = '=', + content = { { '' } }, + pos = 0, + }, + }, + } feed('1+2') - local expectation = {{ - firstc = ":", - content = {{"xx"}}, - pos = 2, - special = {'"', true}, - }, { - firstc = "=", - content = {{"1", 6}, {"+", 7}, {"2", 6}}, - pos = 3, - }} - - screen:expect{grid=[[ + local expectation = { + { + firstc = ':', + content = { { 'xx' } }, + pos = 2, + special = { '"', true }, + }, + { + firstc = '=', + content = { { '1', 6 }, { '+', 7 }, { '2', 6 } }, + pos = 3, + }, + } + + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline=expectation} + ]], + cmdline = expectation, + } -- erase information, so we check if it is retransmitted - command("mode") - screen:expect{grid=[[ + command('mode') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline=expectation, reset=true} - + ]], + cmdline = expectation, + reset = true, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"xx3"}}, - pos = 3, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'xx3' } }, + pos = 3, + }, + }, + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } end) - it("works with function definitions", function() + it('works with function definitions', function() feed(':function Foo()<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - }} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + }, + } feed('line1<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - {{' line1'}}, - }} - - command("mode") - screen:expect{grid=[[ + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + { { ' line1' } }, + }, + } + + command('mode') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Foo()'}}, - {{' line1'}}, - }, reset=true} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Foo()' } }, + { { ' line1' } }, + }, + reset = true, + } feed('endfunction<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } -- Try once more, to check buffer is reinitialized. #8007 feed(':function Bar()<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - indent = 2, - firstc = ":", - content = {{""}}, - pos = 0, - }}, cmdline_block = { - {{'function Bar()'}}, - }} + ]], + cmdline = { + { + indent = 2, + firstc = ':', + content = { { '' } }, + pos = 0, + }, + }, + cmdline_block = { + { { 'function Bar()' } }, + }, + } feed('endfunction<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} - + ]], + } end) - it("works with cmdline window", function() + it('works with cmdline window', function() feed(':make') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } feed('<c-f>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]]} + ]], + } -- nested cmdline feed(':yank') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]], cmdline={nil, { - firstc = ":", - content = {{"yank"}}, - pos = 4, - }}} - - command("mode") - screen:expect{grid=[[ + ]], + cmdline = { + nil, + { + firstc = ':', + content = { { 'yank' } }, + pos = 4, + }, + }, + } + + command('mode') + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]], cmdline={nil, { - firstc = ":", - content = {{"yank"}}, - pos = 4, - }}, reset=true} - - feed("<c-c>") - screen:expect{grid=[[ + ]], + cmdline = { + nil, + { + firstc = ':', + content = { { 'yank' } }, + pos = 4, + }, + }, + reset = true, + } + + feed('<c-c>') + screen:expect { + grid = [[ | {2:[No Name] }| {1::}mak^e | {3:[Command Line] }| | - ]]} + ]], + } - feed("<c-c>") - screen:expect{grid=[[ + feed('<c-c>') + screen:expect { + grid = [[ ^ | {2:[No Name] }| {1::}make | {3:[Command Line] }| | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} - - command("redraw!") - screen:expect{grid=[[ + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } + + command('redraw!') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"make"}}, - pos = 4, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'make' } }, + pos = 4, + }, + }, + } end) it('works with inputsecret()', function() feed(":call inputsecret('secret:')<cr>abc123") - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - prompt = "secret:", - content = {{"******"}}, - pos = 6, - }}} + ]], + cmdline = { + { + prompt = 'secret:', + content = { { '******' } }, + pos = 6, + }, + }, + } end) it('works with highlighted cmdline', function() @@ -427,23 +502,33 @@ local function test_cmdline(linegrid) "map <f5> :let x = input({'prompt':'>'})<cr> ]]) screen:set_default_attr_ids({ - RBP1={background = Screen.colors.Red}, - RBP2={background = Screen.colors.Yellow}, - EOB={bold = true, foreground = Screen.colors.Blue1}, + RBP1 = { background = Screen.colors.Red }, + RBP2 = { background = Screen.colors.Yellow }, + EOB = { bold = true, foreground = Screen.colors.Blue1 }, }) feed('<f5>(a(b)a)') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {EOB:~ }| - {EOB:~ }| - {EOB:~ }| + {EOB:~ }|*3 | - ]], cmdline={{ - prompt = '>', - content = {{'(', 'RBP1'}, {'a'}, {'(', 'RBP2'}, {'b'}, - { ')', 'RBP2'}, {'a'}, {')', 'RBP1'}}, - pos = 7, - }}} + ]], + cmdline = { + { + prompt = '>', + content = { + { '(', 'RBP1' }, + { 'a' }, + { '(', 'RBP2' }, + { 'b' }, + { ')', 'RBP2' }, + { 'a' }, + { ')', 'RBP1' }, + }, + pos = 7, + }, + }, + } end) it('works together with ext_wildmenu', function() @@ -461,79 +546,102 @@ local function test_cmdline(linegrid) screen:set_option('ext_wildmenu', true) feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign jump"}}, - pos = 9, - }}, wildmenu_items=expected, wildmenu_pos=1} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign jump' } }, + pos = 9, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 1, + } feed('<left><left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign "}}, - pos = 5, - }}, wildmenu_items=expected, wildmenu_pos=-1} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign ' } }, + pos = 5, + }, + }, + wildmenu_items = expected, + wildmenu_pos = -1, + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign definea"}}, - pos = 12, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign definea' } }, + pos = 12, + }, + }, + } end) it('works together with ext_popupmenu', function() local expected = { - {'define', '', '', ''}, - {'jump', '', '', ''}, - {'list', '', '', ''}, - {'place', '', '', ''}, - {'undefine', '', '', ''}, - {'unplace', '', '', ''}, + { 'define', '', '', '' }, + { 'jump', '', '', '' }, + { 'list', '', '', '' }, + { 'place', '', '', '' }, + { 'undefine', '', '', '' }, + { 'unplace', '', '', '' }, } command('set wildmode=full') @@ -541,90 +649,115 @@ local function test_cmdline(linegrid) screen:set_option('ext_popupmenu', true) feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } }, + } feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign jump"}}, - pos = 9, - }}, popupmenu={items=expected, pos=1, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign jump' } }, + pos = 9, + }, + }, + popupmenu = { items = expected, pos = 1, anchor = { -1, 0, 5 } }, + } feed('<left><left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign "}}, - pos = 5, - }}, popupmenu={items=expected, pos=-1, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign ' } }, + pos = 5, + }, + }, + popupmenu = { items = expected, pos = -1, anchor = { -1, 0, 5 } }, + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + popupmenu = { items = expected, pos = 0, anchor = { -1, 0, 5 } }, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign definea"}}, - pos = 12, - }}} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign definea' } }, + pos = 12, + }, + }, + } feed('<esc>') -- check positioning with multibyte char in pattern - command("e långfile1") - command("sp långfile2") + command('e långfile1') + command('sp långfile2') feed(':b lå<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {3:långfile2 }| | {2:långfile1 }| | - ]], popupmenu={ - anchor = { -1, 0, 2 }, - items = {{ "långfile1", "", "", "" }, { "långfile2", "", "", "" }}, - pos = 0 - }, cmdline={{ - content = {{ "b långfile1" }}, - firstc = ":", - pos = 12 - }}} + ]], + popupmenu = { + anchor = { -1, 0, 2 }, + items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } }, + pos = 0, + }, + cmdline = { + { + content = { { 'b långfile1' } }, + firstc = ':', + pos = 12, + }, + }, + } end) it('ext_wildmenu takes precedence over ext_popupmenu', function() @@ -643,17 +776,22 @@ local function test_cmdline(linegrid) screen:set_option('ext_popupmenu', true) feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - firstc = ":", - content = {{"sign define"}}, - pos = 11, - }}, wildmenu_items=expected, wildmenu_pos=0} + ]], + cmdline = { + { + firstc = ':', + content = { { 'sign define' } }, + pos = 11, + }, + }, + wildmenu_items = expected, + wildmenu_pos = 0, + } end) it("doesn't send invalid events when aborting mapping #10000", function() @@ -661,85 +799,100 @@ local function test_cmdline(linegrid) command('cnoremap ab c') feed(':xa') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]], cmdline={{ - content = { { "x" } }, - firstc = ":", - pos = 1, - special = { "a", false } - }}} + ]], + cmdline = { + { + content = { { 'x' } }, + firstc = ':', + pos = 1, + special = { 'a', false }, + }, + }, + } -- This used to send an invalid event where pos where larger than the total -- length of content. Checked in _handle_cmdline_show. feed('<esc>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) - end -- the representation of cmdline and cmdline_block contents changed with ext_linegrid -- (which uses indexed highlights) so make sure to test both -describe('ui/ext_cmdline', function() test_cmdline(true) end) -describe('ui/ext_cmdline (legacy highlights)', function() test_cmdline(false) end) +describe('ui/ext_cmdline', function() + test_cmdline(true) +end) +describe('ui/ext_cmdline (legacy highlights)', function() + test_cmdline(false) +end) describe('cmdline redraw', function() local screen before_each(function() clear() - screen = new_screen({rgb=true}) + screen = new_screen({ rgb = true }) end) it('with timer', function() feed(':012345678901234567890123456789') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]]} + ]], + } command('call timer_start(0, {-> 1})') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]], unchanged=true, timeout=100} + ]], + unchanged = true, + timeout = 100, + } end) it('with <Cmd>', function() if is_os('bsd') then pending('FIXME #10804') end - command('cmap a <Cmd>call sin(0)<CR>') -- no-op + command('cmap a <Cmd>call sin(0)<CR>') -- no-op feed(':012345678901234567890123456789') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]]} + ]], + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| :012345678901234567890123| 456789^ | - ]], unchanged=true} + ]], + unchanged = true, + } end) it('after pressing Ctrl-C in cmdwin in Visual mode #18967', function() @@ -748,26 +901,20 @@ describe('cmdline redraw', function() feed('q:iabc<Esc>vhh') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| {1::}^a{8:bc} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[Command Line] }| {9:-- VISUAL --} | ]]) feed('<C-C>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| {1::}a{8:bc} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[Command Line] }| :^abc | ]]) @@ -775,80 +922,80 @@ describe('cmdline redraw', function() it('with rightleftcmd', function() command('set rightleft rightleftcmd=search shortmess+=s') - meths.buf_set_lines(0, 0, -1, true, {"let's rock!"}) - screen:expect{grid=[[ + api.nvim_buf_set_lines(0, 0, -1, true, { "let's rock!" }) + screen:expect { + grid = [[ !kcor s'te^l| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 | - ]]} + ]], + } feed '/' - screen:expect{grid=[[ + screen:expect { + grid = [[ !kcor s'tel| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ /| - ]]} + ]], + } feed "let's" -- note: cursor looks off but looks alright in real use -- when rendered as a block so it touches the end of the text - screen:expect{grid=[[ + screen:expect { + grid = [[ !kcor {2:s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ s'tel/| - ]]} + ]], + } -- cursor movement - feed "<space>" - screen:expect{grid=[[ + feed '<space>' + screen:expect { + grid = [[ !kcor{2: s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ s'tel/| - ]]} + ]], + } - feed "rock" - screen:expect{grid=[[ + feed 'rock' + screen:expect { + grid = [[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ kcor s'tel/| - ]]} + ]], + } - feed "<right>" - screen:expect{grid=[[ + feed '<right>' + screen:expect { + grid = [[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^kcor s'tel/| - ]]} + ]], + } - feed "<left>" - screen:expect{grid=[[ + feed '<left>' + screen:expect { + grid = [[ !{2:kcor s'tel}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ^ kcor s'tel/| - ]]} + ]], + } - feed "<cr>" - screen:expect{grid=[[ + feed '<cr>' + screen:expect { + grid = [[ !{10:kcor s'te^l}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 kcor s'tel/ | - ]]} + ]], + } end) end) @@ -863,48 +1010,52 @@ describe('statusline is redrawn on entering cmdline', function() it('from normal mode', function() command('set statusline=%{mode()}') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:n }| | - ]]} + ]], + } feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:c }| :^ | - ]]} + ]], + } end) it('from normal mode when : is mapped', function() command('set statusline=%{mode()}') command('nnoremap ; :') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:n }| | - ]]} + ]], + } feed(';') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:c }| :^ | - ]]} + ]], + } end) it('with scrolled messages', function() - screen:try_resize(35,14) + screen:try_resize(35, 14) exec([[ let g:count = 0 autocmd CmdlineEnter * let g:count += 1 @@ -914,30 +1065,28 @@ describe('statusline is redrawn on entering cmdline', function() setlocal winbar=%{mode()}%{g:count} ]]) feed(':echoerr doesnotexist<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c1 }| | {3:c1 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed(':echoerr doesnotexist<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c2 }| | {3:c2 }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| {4:E121: Undefined variable: doesnotex}| {4:ist} | @@ -946,10 +1095,12 @@ describe('statusline is redrawn on entering cmdline', function() {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed(':echoerr doesnotexist<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:c3 }| | {3:c3 }| @@ -964,61 +1115,60 @@ describe('statusline is redrawn on entering cmdline', function() {4:ist} | {5:Press ENTER or type command to cont}| {5:inue}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:n3 }| ^ | {3:n3 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 {2:[No Name] }| | - ]]} + ]], + } end) describe('if custom statusline is set by', function() before_each(function() command('set statusline=') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[No Name] }| | - ]]} + ]], + } end) it('CmdlineEnter autocommand', function() command('autocmd CmdlineEnter * set statusline=command') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:command }| :^ | - ]]} + ]], + } end) it('ModeChanged autocommand', function() command('autocmd ModeChanged *:c set statusline=command') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:command }| :^ | - ]]} + ]], + } end) end) end) @@ -1027,9 +1177,9 @@ it('tabline is not redrawn in Ex mode #24122', function() clear() local screen = Screen.new(60, 5) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [1] = {bold = true, reverse = true}, -- MsgSeparator - [2] = {reverse = true}, -- TabLineFill + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { bold = true, reverse = true }, -- MsgSeparator + [2] = { reverse = true }, -- TabLineFill }) screen:attach() @@ -1044,28 +1194,32 @@ it('tabline is not redrawn in Ex mode #24122', function() ]]) feed('gQ') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:foo }| | {1: }| Entering Ex mode. Type "visual" to go to Normal mode. | :^ | - ]]} + ]], + } feed('echo 1<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }| Entering Ex mode. Type "visual" to go to Normal mode. | :echo 1 | 1 | :^ | - ]]} + ]], + } end) -describe("cmdline height", function() +describe('cmdline height', function() before_each(clear) - it("does not crash resized screen #14263", function() + it('does not crash resized screen #14263', function() local screen = Screen.new(25, 10) screen:attach() command('set cmdheight=9999') @@ -1089,329 +1243,341 @@ describe('cmdheight=0', function() clear() screen = Screen.new(25, 5) screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue}; - [2] = {bold = true, reverse = true}; - [3] = {bold = true}; - [4] = {foreground = Screen.colors.White, background = Screen.colors.Red}; - [5] = {foreground = Screen.colors.SeaGreen4, bold = true}; - [6] = {reverse = true}; - [7] = {background = Screen.colors.Yellow}; + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true, reverse = true }, + [3] = { bold = true }, + [4] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + [5] = { foreground = Screen.colors.SeaGreen4, bold = true }, + [6] = { reverse = true }, + [7] = { background = Screen.colors.Yellow }, } screen:attach() end) - it("with redrawdebug=invalid resize -1", function() - command("set redrawdebug=invalid cmdheight=0 noruler laststatus=0") - screen:expect{grid=[[ + it('with redrawdebug=invalid resize -1', function() + command('set redrawdebug=invalid cmdheight=0 noruler laststatus=0') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} - feed(":resize -1<CR>") - screen:expect{grid=[[ + {1:~ }|*4 + ]], + } + feed(':resize -1<CR>') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } assert_alive() end) - it("with cmdheight=1 noruler laststatus=2", function() - command("set cmdheight=1 noruler laststatus=2") - screen:expect{grid=[[ + it('with cmdheight=1 noruler laststatus=2', function() + command('set cmdheight=1 noruler laststatus=2') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | - ]]} + ]], + } end) - it("with cmdheight=0 noruler laststatus=2", function() - command("set cmdheight=0 noruler laststatus=2") - screen:expect{grid=[[ + it('with cmdheight=0 noruler laststatus=2', function() + command('set cmdheight=0 noruler laststatus=2') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| - ]]} + ]], + } end) - it("with cmdheight=0 ruler laststatus=0", function() - command("set cmdheight=0 ruler laststatus=0") - screen:expect{grid=[[ + it('with cmdheight=0 ruler laststatus=0', function() + command('set cmdheight=0 ruler laststatus=0') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) - it("with cmdheight=0 ruler laststatus=0", function() - command("set cmdheight=0 noruler laststatus=0 showmode") + it('with cmdheight=0 ruler laststatus=0', function() + command('set cmdheight=0 noruler laststatus=0 showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={}} + {1:~ }|*4 + ]], + showmode = {}, + } feed('<Esc>') eq(0, eval('&cmdheight')) end) - it("with cmdheight=0 ruler rulerformat laststatus=0", function() - command("set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode") + it('with cmdheight=0 ruler rulerformat laststatus=0', function() + command('set cmdheight=0 noruler laststatus=0 rulerformat=%l,%c%= showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={}} + {1:~ }|*4 + ]], + showmode = {}, + } feed('<Esc>') eq(0, eval('&cmdheight')) end) - it("with showmode", function() - command("set cmdheight=1 noruler laststatus=0 showmode") + it('with showmode', function() + command('set cmdheight=1 noruler laststatus=0 showmode') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3:-- INSERT --} | - ]]} + ]], + } feed('<Esc>') eq(1, eval('&cmdheight')) end) - it("when using command line", function() - command("set cmdheight=0 noruler laststatus=0") + it('when using command line', function() + command('set cmdheight=0 noruler laststatus=0') feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :^ | - ]]} + ]], + } eq(0, eval('&cmdheight')) feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={}} + {1:~ }|*4 + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) end) - it("when using input()", function() - command("set cmdheight=0 noruler laststatus=0") + it('when using input()', function() + command('set cmdheight=0 noruler laststatus=0') feed(':call input("foo >")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {2: }| :call input("foo >") | foo >^ | - ]]} + ]], + } eq(0, eval('&cmdheight')) feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={}} + {1:~ }|*4 + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) end) - it("with winbar and splits", function() - command("set cmdheight=0 noruler laststatus=3 winbar=foo") + it('with winbar and splits', function() + command('set cmdheight=0 noruler laststatus=3 winbar=foo') feed(':split<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2: }| :split | {4:E36: Not enough room} | {5:Press ENTER or type comma}| {5:nd to continue}^ | - ]]} + ]], + } feed('<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| - ]]} + ]], + } feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :^ | - ]]} + ]], + } feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| - ]], showmode={}} + ]], + showmode = {}, + } eq(0, eval('&cmdheight')) assert_alive() end) - it("when macro with lastline", function() - command("set cmdheight=0 display=lastline") + it('when macro with lastline', function() + command('set cmdheight=0 display=lastline') feed('qq') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], unchanged=true} + {1:~ }|*4 + ]], + unchanged = true, + } end) - it("when substitute text", function() - command("set cmdheight=0 noruler laststatus=3") + it('when substitute text', function() + command('set cmdheight=0 noruler laststatus=3') feed('ifoo<ESC>') - screen:expect{grid=[[ + screen:expect { + grid = [[ fo^o | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] [+] }| - ]]} + ]], + } feed(':%s/foo/bar/gc<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {6:foo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {5:replace wi...q/l/^E/^Y)?}^ | - ]]} + ]], + } feed('y') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^bar | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] [+] }| - ]]} + ]], + } assert_alive() end) - it("when window resize", function() - command("set cmdheight=0") + it('when window resize', function() + command('set cmdheight=0') feed('<C-w>+') eq(0, eval('&cmdheight')) end) - it("with non-silent mappings with cmdline", function() - command("set cmdheight=0") - command("map <f3> :nohlsearch<cr>") + it('with non-silent mappings with cmdline', function() + command('set cmdheight=0') + command('map <f3> :nohlsearch<cr>') feed('iaabbaa<esc>/aa<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:^aa}bb{7:aa} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } feed('<f3>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^aabbaa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it('with silent! at startup', function() - clear{args={'-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()'}} + clear { args = { '-c', 'set cmdheight=0', '-c', 'autocmd VimEnter * silent! call Foo()' } } screen:attach() -- doesn't crash while not displaying silent! error message - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it('with multigrid', function() - clear{args={'--cmd', 'set cmdheight=0'}} - screen:attach{ext_multigrid=true} - meths.buf_set_lines(0, 0, -1, true, {'p'}) - screen:expect{grid=[[ + clear { args = { '--cmd', 'set cmdheight=0' } } + screen:attach { ext_multigrid = true } + api.nvim_buf_set_lines(0, 0, -1, true, { 'p' }) + screen:expect { + grid = [[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*5 ## grid 2 ^p | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } feed '/p' - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*4 [3:-------------------------]| ## grid 2 {6:p} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 /p^ | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } end) it('winbar is redrawn on entering cmdline and :redrawstatus #20336', function() @@ -1423,8 +1589,7 @@ describe('cmdheight=0', function() screen:expect([[ {3:c :}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :^ | ]]) feed('echo') @@ -1432,16 +1597,14 @@ describe('cmdheight=0', function() screen:expect([[ {3:c :}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :echo^ | ]]) command('redrawstatus') screen:expect([[ {3:c :echo}| | - {1:~ }| - {1:~ }| + {1:~ }|*2 :echo^ | ]]) end) @@ -1452,28 +1615,17 @@ describe('cmdheight=0', function() command('vsplit') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*8 ]]) feed(':') command('split') feed('<Esc>') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 ]]) command('resize 2') screen:expect([[ @@ -1481,25 +1633,17 @@ describe('cmdheight=0', function() {1:~ }│{1:~ }| {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*5 ]]) feed(':') command('wincmd =') feed('<Esc>') screen:expect([[ ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] }│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 ]]) end) @@ -1508,10 +1652,7 @@ describe('cmdheight=0', function() feed('d') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) assert_alive() end) @@ -1521,52 +1662,48 @@ describe('cmdheight=0', function() command('resize +1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | ]]) command('set cmdheight=0') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| - ]]} + ]], + } command('resize -1') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] }| | - ]]} + ]], + } command('resize +1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] }| ]]) end) - it("cannot be resized at all with external messages", function() + it('cannot be resized at all with external messages', function() clear() - screen = new_screen({rgb=true, ext_messages=true}) + screen = new_screen({ rgb = true, ext_messages = true }) command('set laststatus=2 mouse=a') command('resize -1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3:[No Name] }| ]]) - meths.input_mouse('left', 'press', '', 0, 6, 10) + api.nvim_input_mouse('left', 'press', '', 0, 6, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 5, 10) + api.nvim_input_mouse('left', 'drag', '', 0, 5, 10) screen:expect_unchanged() end) end) diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua index 05057ca080..871e9a0790 100644 --- a/test/functional/ui/cursor_spec.lua +++ b/test/functional/ui/cursor_spec.lua @@ -1,6 +1,6 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, meths = helpers.clear, helpers.meths +local clear, api = helpers.clear, helpers.api local eq = helpers.eq local command = helpers.command @@ -27,7 +27,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'n' }, + short_name = 'n', + }, [2] = { blinkoff = 0, blinkon = 0, @@ -40,7 +41,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'v' }, + short_name = 'v', + }, [3] = { blinkoff = 0, blinkon = 0, @@ -53,7 +55,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'i' }, + short_name = 'i', + }, [4] = { blinkoff = 0, blinkon = 0, @@ -66,7 +69,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'r' }, + short_name = 'r', + }, [5] = { blinkoff = 0, blinkon = 0, @@ -79,7 +83,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'c' }, + short_name = 'c', + }, [6] = { blinkoff = 0, blinkon = 0, @@ -92,7 +97,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'ci' }, + short_name = 'ci', + }, [7] = { blinkoff = 0, blinkon = 0, @@ -105,7 +111,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'cr' }, + short_name = 'cr', + }, [8] = { blinkoff = 0, blinkon = 0, @@ -118,7 +125,8 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 'o' }, + short_name = 'o', + }, [9] = { blinkoff = 0, blinkon = 0, @@ -131,35 +139,43 @@ describe('ui/cursor', function() attr = {}, attr_lm = {}, mouse_shape = 0, - short_name = 've' }, + short_name = 've', + }, [10] = { name = 'cmdline_hover', mouse_shape = 0, - short_name = 'e' }, + short_name = 'e', + }, [11] = { name = 'statusline_hover', mouse_shape = 0, - short_name = 's' }, + short_name = 's', + }, [12] = { name = 'statusline_drag', mouse_shape = 0, - short_name = 'sd' }, + short_name = 'sd', + }, [13] = { name = 'vsep_hover', mouse_shape = 0, - short_name = 'vs' }, + short_name = 'vs', + }, [14] = { name = 'vsep_drag', mouse_shape = 0, - short_name = 'vd' }, + short_name = 'vd', + }, [15] = { name = 'more', mouse_shape = 0, - short_name = 'm' }, + short_name = 'm', + }, [16] = { name = 'more_lastline', mouse_shape = 0, - short_name = 'ml' }, + short_name = 'ml', + }, [17] = { blinkoff = 0, blinkon = 0, @@ -171,8 +187,9 @@ describe('ui/cursor', function() id_lm = 0, attr = {}, attr_lm = {}, - short_name = 'sm' }, - } + short_name = 'sm', + }, + } screen:expect(function() -- Default 'guicursor', published on startup. @@ -184,38 +201,55 @@ describe('ui/cursor', function() -- Event is published ONLY if the cursor style changed. screen._mode_info = nil command("echo 'test'") - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 test | - ]], condition=function() - eq(nil, screen._mode_info) - end} + ]], + condition = function() + eq(nil, screen._mode_info) + end, + } -- Change the cursor style. helpers.command('hi Cursor guibg=DarkGray') - helpers.command('set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20' - ..',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor' - ..',sm:block-blinkwait175-blinkoff150-blinkon175') + helpers.command( + 'set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr-o:hor20' + .. ',a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor' + .. ',sm:block-blinkwait175-blinkoff150-blinkon175' + ) -- Update the expected values. for _, m in ipairs(expected_mode_info) do if m.name == 'showmatch' then - if m.blinkon then m.blinkon = 175 end - if m.blinkoff then m.blinkoff = 150 end - if m.blinkwait then m.blinkwait = 175 end + if m.blinkon then + m.blinkon = 175 + end + if m.blinkoff then + m.blinkoff = 150 + end + if m.blinkwait then + m.blinkwait = 175 + end else - if m.blinkon then m.blinkon = 250 end - if m.blinkoff then m.blinkoff = 400 end - if m.blinkwait then m.blinkwait = 700 end + if m.blinkon then + m.blinkon = 250 + end + if m.blinkoff then + m.blinkoff = 400 + end + if m.blinkwait then + m.blinkwait = 700 + end end if m.hl_id then - m.hl_id = 64 - m.attr = {background = Screen.colors.DarkGray} + m.hl_id = 64 + m.attr = { background = Screen.colors.DarkGray } + end + if m.id_lm then + m.id_lm = 69 end - if m.id_lm then m.id_lm = 67 end end -- Assert the new expectation. @@ -232,10 +266,10 @@ describe('ui/cursor', function() -- Update the expected values. for _, m in ipairs(expected_mode_info) do if m.hl_id then - m.attr = {background = Screen.colors.Red} + m.attr = { background = Screen.colors.Red } end if m.id_lm then - m.attr_lm = {background = Screen.colors.Green} + m.attr_lm = { background = Screen.colors.Green } end end -- Assert the new expectation. @@ -250,23 +284,27 @@ describe('ui/cursor', function() for _, m in ipairs(expected_mode_info) do if m.hl_id then - m.attr = {background = Screen.colors.Red, blend = 100} + m.attr = { background = Screen.colors.Red, blend = 100 } end end - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 test | - ]], condition=function() - eq(expected_mode_info, screen._mode_info) - end + ]], + condition = function() + eq(expected_mode_info, screen._mode_info) + end, } -- Another cursor style. - meths.set_option_value('guicursor', 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' - ..',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', {}) + api.nvim_set_option_value( + 'guicursor', + 'n-v-c:ver35-blinkwait171-blinkoff172-blinkon173' + .. ',ve:hor35,o:ver50,i-ci:block,r-cr:hor90,sm:ver42', + {} + ) screen:expect(function() local named = {} for _, m in ipairs(screen._mode_info) do @@ -288,9 +326,13 @@ describe('ui/cursor', function() end) -- If there is no setting for guicursor, it becomes the default setting. - meths.set_option_value('guicursor', 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', {}) + api.nvim_set_option_value( + 'guicursor', + 'n:ver35-blinkwait171-blinkoff172-blinkon173-Cursor/lCursor', + {} + ) screen:expect(function() - for _,m in ipairs(screen._mode_info) do + for _, m in ipairs(screen._mode_info) do if m.name ~= 'normal' then eq('block', m.cursor_shape or 'block') eq(0, m.blinkon or 0) @@ -304,7 +346,7 @@ describe('ui/cursor', function() end) it("empty 'guicursor' sets cursor_shape=block in all modes", function() - meths.set_option_value('guicursor', '', {}) + api.nvim_set_option_value('guicursor', '', {}) screen:expect(function() -- Empty 'guicursor' sets enabled=false. eq(false, screen._cursor_style_enabled) @@ -318,5 +360,4 @@ describe('ui/cursor', function() end end) end) - end) diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index e8fcfc46fc..e57e719192 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -7,9 +7,8 @@ local insert = helpers.insert local exec_lua = helpers.exec_lua local exec = helpers.exec local expect_events = helpers.expect_events -local meths = helpers.meths -local funcs = helpers.funcs -local curbufmeths = helpers.curbufmeths +local api = helpers.api +local fn = helpers.fn local command = helpers.command local eq = helpers.eq local assert_alive = helpers.assert_alive @@ -40,6 +39,7 @@ describe('decorations providers', function() [16] = {special = Screen.colors.Red, undercurl = true}, [17] = {foreground = Screen.colors.Red}, [18] = {bold = true, foreground = Screen.colors.SeaGreen}; + [19] = {bold = true}; } end) @@ -212,9 +212,7 @@ describe('decorations providers', function() {15:i} am not capitalized. | I am a {16:speling} {16:mistakke}. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -227,9 +225,7 @@ describe('decorations providers', function() {15:^i} am not capitalized. | I am a {16:speling} {16:mistakke}. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -242,24 +238,20 @@ describe('decorations providers', function() {15:i} am not capitalized. | I am a {16:^speling} {16:mistakke}. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} -- spell=false with higher priority does disable spell - local ns = meths.create_namespace "spell" - local id = curbufmeths.set_extmark(ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false }) + local ns = api.nvim_create_namespace "spell" + local id = api.nvim_buf_set_extmark(0, ns, 0, 0, { priority = 30, end_row = 2, end_col = 23, spell = false }) screen:expect{grid=[[ I am well written text. | i am not capitalized. | I am a ^speling mistakke. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -269,24 +261,20 @@ describe('decorations providers', function() i am not capitalized. | I am a ^speling mistakke. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {17:search hit BOTTOM, continuing at TOP} | ]]} command('echo ""') -- spell=false with lower priority doesn't disable spell - curbufmeths.set_extmark(ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { id = id, priority = 10, end_row = 2, end_col = 23, spell = false }) screen:expect{grid=[[ I am well written text. | {15:i} am not capitalized. | I am a {16:^speling} {16:mistakke}. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -296,9 +284,7 @@ describe('decorations providers', function() {15:i} am not capitalized. | I am a {16:speling} {16:^mistakke}. | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -320,7 +306,7 @@ describe('decorations providers', function() LineNr = {italic=true, bg="Magenta"}; Comment = {fg="#FF0000", bg = 80*256+40}; CursorLine = {link="ErrorMsg"}; - } do meths.set_hl(ns1, k, v) end + } do api.nvim_set_hl(ns1, k, v) end screen:expect{grid=[[ {3: 1 }{4:// just to see if there was an accid}| @@ -341,7 +327,7 @@ describe('decorations providers', function() | ]]} - meths.set_hl_ns(ns1) + api.nvim_set_hl_ns(ns1) screen:expect{grid=[[ {10: 1 }{11:// just to see if there was an accid}| {10: }{11:ent} | @@ -401,7 +387,7 @@ describe('decorations providers', function() highlight link LinkGroup OriginalGroup ]] - meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + api.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) screen:expect{grid=[[ // just to see if there was an accident | // on Mulholland Drive | @@ -413,8 +399,8 @@ describe('decorations providers', function() | ]]} - meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) - meths.set_hl_ns(ns1) + api.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue'}) + api.nvim_set_hl_ns(ns1) screen:expect{grid=[[ // just to see if there was an accident | @@ -437,7 +423,7 @@ describe('decorations providers', function() highlight link LinkGroup OriginalGroup ]] - meths.buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) + api.nvim_buf_set_virtual_text(0, 0, 2, {{'- not red', 'LinkGroup'}}, {}) screen:expect{grid=[[ // just to see if there was an accident | // on Mulholland Drive | @@ -449,8 +435,8 @@ describe('decorations providers', function() | ]]} - meths.set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) - meths.set_hl_ns(ns1) + api.nvim_set_hl(ns1, 'LinkGroup', {fg = 'Blue', default=true}) + api.nvim_set_hl_ns(ns1) feed 'k' screen:expect{grid=[[ @@ -629,9 +615,9 @@ describe('decorations providers', function() vim.api.nvim_buf_set_lines(0, 0, -1, false, lines) ]]) setup_provider([[ - local function on_do(kind, winid, bufnr, topline, botline_guess) + local function on_do(kind, winid, bufnr, topline, botline) if kind == 'win' then - if topline < 100 and botline_guess > 100 then + if topline < 100 and botline > 100 then api.nvim_buf_set_extmark(bufnr, ns1, 99, -1, { sign_text = 'X' }) else api.nvim_buf_clear_namespace(bufnr, ns1, 0, -1) @@ -640,7 +626,7 @@ describe('decorations providers', function() end ]]) command([[autocmd CursorMoved * call line('w$')]]) - meths.win_set_cursor(0, {100, 0}) + api.nvim_win_set_cursor(0, {100, 0}) screen:expect([[ {14: }hello97 | {14: }hello98 | @@ -651,7 +637,7 @@ describe('decorations providers', function() {14: }hello103 | | ]]) - meths.win_set_cursor(0, {1, 0}) + api.nvim_win_set_cursor(0, {1, 0}) screen:expect([[ ^hello1 | hello2 | @@ -669,7 +655,7 @@ describe('decorations providers', function() eok = true ]]) setup_provider([[ - local function on_do(kind, winid, bufnr, topline, botline_guess) + local function on_do(kind, winid, bufnr, topline, botline) if kind == 'line' then api.nvim_buf_set_extmark(bufnr, ns1, 1, -1, { sign_text = 'X' }) eok = pcall(api.nvim_buf_clear_namespace, bufnr, ns1, 0, -1) @@ -701,6 +687,77 @@ describe('decorations providers', function() {18:Press ENTER or type command to continue}^ | ]]} end) + + it('can add new providers during redraw #26652', function() + setup_provider [[ + local ns = api.nvim_create_namespace('test_no_add') + function on_do(...) + api.nvim_set_decoration_provider(ns, {}) + end + ]] + + helpers.assert_alive() + end) + + it('supports subpriorities (order of definitions in a query file #27131)', function() + insert(mulholland) + setup_provider [[ + local test_ns = api.nvim_create_namespace('mulholland') + function on_do(event, ...) + if event == "line" then + local win, buf, line = ... + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + end_row = line + 1, + hl_eol = true, + hl_group = 'Comment', + ephemeral = true, + priority = 100, + _subpriority = 20, + }) + + -- This extmark is set last but has a lower subpriority, so the first extmark "wins" + api.nvim_buf_set_extmark(buf, test_ns, line, 0, { + end_row = line + 1, + hl_eol = true, + hl_group = 'String', + ephemeral = true, + priority = 100, + _subpriority = 10, + }) + end + end + ]] + + screen:expect{grid=[[ + {4:// just to see if there was an accident }| + {4:// on Mulholland Drive }| + {4:try_start(); }| + {4:bufref_T save_buf; }| + {4:switch_buffer(&save_buf, buf); }| + {4:posp = getmark(mark, false); }| + {4:restore_buffer(&save_buf);^ }| + | + ]]} + end) + + it('is not invoked repeatedly in Visual mode with vim.schedule() #20235', function() + exec_lua([[_G.cnt = 0]]) + setup_provider([[ + function on_do(event, ...) + if event == 'win' then + vim.schedule(function() end) + _G.cnt = _G.cnt + 1 + end + end + ]]) + feed('v') + screen:expect([[ + ^ | + {1:~ }|*6 + {19:-- VISUAL --} | + ]]) + eq(2, exec_lua([[return _G.cnt]])) + end) end) local example_text = [[ @@ -749,14 +806,14 @@ describe('extmark decorations', function() [23] = {foreground = Screen.colors.Magenta1, background = Screen.colors.LightGrey}; [24] = {bold = true}; [25] = {background = Screen.colors.LightRed}; - [26] = {background=Screen.colors.DarkGrey, foreground=Screen.colors.LightGrey}; - [27] = {background = Screen.colors.Plum1}; + [26] = {background = Screen.colors.DarkGrey, foreground = Screen.colors.LightGrey}; + [27] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Black}; [28] = {underline = true, foreground = Screen.colors.SlateBlue}; - [29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGray, underline = true}; - [30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGray, underline = true}; + [29] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.LightGrey, underline = true}; + [30] = {foreground = Screen.colors.DarkCyan, background = Screen.colors.LightGrey, underline = true}; [31] = {underline = true, foreground = Screen.colors.DarkCyan}; [32] = {underline = true}; - [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray}; + [33] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}; [34] = {background = Screen.colors.Yellow}; [35] = {background = Screen.colors.Yellow, bold = true, foreground = Screen.colors.Blue}; [36] = {foreground = Screen.colors.Blue1, bold = true, background = Screen.colors.Red}; @@ -765,9 +822,12 @@ describe('extmark decorations', function() [39] = {foreground = Screen.colors.Blue1, background = Screen.colors.LightCyan1, bold = true}; [40] = {reverse = true}; [41] = {bold = true, reverse = true}; + [42] = {undercurl = true, special = Screen.colors.Red}; + [43] = {background = Screen.colors.Yellow, undercurl = true, special = Screen.colors.Red}; + [44] = {background = Screen.colors.LightMagenta}; } - ns = meths.create_namespace 'test' + ns = api.nvim_create_namespace 'test' end) it('empty virtual text at eol should not break colorcolumn #17860', function() @@ -787,11 +847,10 @@ describe('extmark decorations', function() colpos = colpos+1 {25: } | end {25: } | end {25: } | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) - meths.buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'}) + api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_text={{''}}, virt_text_pos='eol'}) screen:expect_unchanged() end) @@ -800,19 +859,19 @@ describe('extmark decorations', function() feed 'gg' for i = 1,9 do - meths.buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, i, 0, { virt_text={{'|', 'LineNr'}}, virt_text_pos='overlay'}) if i == 3 or (i >= 6 and i <= 9) then - meths.buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, i, 4, { virt_text={{'|', 'NonText'}}, virt_text_pos='overlay'}) end end - meths.buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 9, 10, { virt_text={{'foo'}, {'bar', 'MoreMsg'}, {'!!', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- can "float" beyond end of line - meths.buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 5, 28, { virt_text={{'loopy', 'ErrorMsg'}}, virt_text_pos='overlay'}) -- bound check: right edge of window - meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork'}, {(' bork'):rep(10), 'ErrorMsg'}}, virt_text_pos='overlay'}) -- empty virt_text should not change anything - meths.buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 6, 16, { virt_text={{''}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | @@ -827,8 +886,7 @@ describe('extmark decorations', function() {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | end | end | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} @@ -857,18 +915,17 @@ describe('extmark decorations', function() s+1 | end | end | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} -- truncating in the middle of a char leaves a space - meths.buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) - meths.buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) - meths.buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_lines(0, 0, 1, true, {'for _,item in ipairs(items) do -- 古古古'}) + api.nvim_buf_set_lines(0, 10, 12, true, {' end -- ??????????', 'end -- ?古古古古?古古'}) + api.nvim_buf_set_extmark(0, ns, 0, 35, { virt_text={{'A', 'ErrorMsg'}, {'AA'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 10, 19, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 11, 21, { virt_text={{'口口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 11, 8, { virt_text={{'口口', 'ErrorMsg'}}, virt_text_pos='overlay'}) screen:expect{grid=[[ ^for _,item in ipairs(i| tems) do -- {4:A}AA 古 | @@ -892,8 +949,7 @@ describe('extmark decorations', function() s+1 | end -- ???????{4:口 }| end -- {4:口口} 古古{4:口口 }| - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} @@ -914,7 +970,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect{grid=[[ ^for _,item in ipairs(items) do -- 古古古 | local text, hl_id_cell, count = unpack(item) | @@ -936,8 +992,8 @@ describe('extmark decorations', function() screen:try_resize(50, 6) insert(('ab'):rep(100)) for i = 0, 9 do - meths.buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) - meths.buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + api.nvim_buf_set_extmark(0, ns, 0, 42 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay'}) + api.nvim_buf_set_extmark(0, ns, 0, 91 + i, { virt_text={{tostring(i), 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) end screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| @@ -962,7 +1018,7 @@ describe('extmark decorations', function() screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| {1:++}{4:89}abababababababababababababababababababa{4:0123456}| - {1:++}^a{18:babab}ababababababababababababababababababababab| + {1:++}^a{27:babab}ababababababababababababababababababababab| {1:++}abababababababababababababababababababababababab| {1:++}ababab | {24:-- VISUAL --} | @@ -972,7 +1028,7 @@ describe('extmark decorations', function() screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| {1:++}{4:89}abababababababababababababababababababa{4:0123456}| - {1:++}{18:ababa}^bababababababababababababababababababababab| + {1:++}{27:ababa}^bababababababababababababababababababababab| {1:++}abababababababababababababababababababababababab| {1:++}ababab | {24:-- VISUAL --} | @@ -981,8 +1037,8 @@ describe('extmark decorations', function() feed('gk') screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| - {1:++}{4:89}aba^b{18:ababababababababababababababababababababab}| - {1:++}{18:a}{4:89}babababababababababababababababababababababab| + {1:++}{4:89}aba^b{27:ababababababababababababababababababababab}| + {1:++}{27:a}{4:89}babababababababababababababababababababababab| {1:++}abababababababababababababababababababababababab| {1:++}ababab | {24:-- VISUAL --} | @@ -991,7 +1047,7 @@ describe('extmark decorations', function() feed('o') screen:expect{grid=[[ ababababababababababababababababababababab{4:01234567}| - {1:++}{4:89}aba{18:bababababababababababababababababababababab}| + {1:++}{4:89}aba{27:bababababababababababababababababababababab}| {1:++}^a{4:89}babababababababababababababababababababababab| {1:++}abababababababababababababababababababababababab| {1:++}ababab | @@ -1033,9 +1089,9 @@ describe('extmark decorations', function() it('virt_text_hide hides overlay virtual text when extmark is off-screen', function() screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + api.nvim_buf_set_lines(0, 0, -1, true, {'-- ' .. ('…'):rep(57)}) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text={{'?????', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) + api.nvim_buf_set_extmark(0, ns, 0, 123, { virt_text={{'!!!!!', 'ErrorMsg'}}, virt_text_pos='overlay', virt_text_hide=true}) screen:expect{grid=[[ {4:^?????}……………………………………………………………………………………………………{4:!!!!!}……| {1:~ }| @@ -1088,10 +1144,10 @@ describe('extmark decorations', function() it('overlay virtual text works on and after a TAB #24022', function() screen:try_resize(40, 3) - meths.buf_set_lines(0, 0, -1, true, {'\t\tline 1'}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + api.nvim_buf_set_lines(0, 0, -1, true, {'\t\tline 1'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = {{'BB', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Search'}}, virt_text_pos = 'overlay', hl_mode = 'combine' }) screen:expect{grid=[[ {34:AA} ^ {34:BB} {34:CC}ne 1 | {1:~ }| @@ -1125,19 +1181,19 @@ describe('extmark decorations', function() colpos {5:=} colpos{5:+}{13:1} | {5:end} | {5:end} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} command 'hi Blendy guibg=Red blend=30' - meths.buf_set_extmark(0, ns, 1, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine'}) - meths.buf_set_extmark(0, ns, 3, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace'}) + command 'hi! Visual guifg=NONE guibg=LightGrey' + api.nvim_buf_set_extmark(0, ns, 1, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 2, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine'}) + api.nvim_buf_set_extmark(0, ns, 3, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace'}) - meths.buf_set_extmark(0, ns, 4, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 5, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine', virt_text_hide=true}) - meths.buf_set_extmark(0, ns, 6, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace', virt_text_hide=true}) + api.nvim_buf_set_extmark(0, ns, 4, 5, { virt_text={{'blendy text - here', 'Blendy'}}, virt_text_pos='overlay', hl_mode='blend', virt_text_hide=true}) + api.nvim_buf_set_extmark(0, ns, 5, 5, { virt_text={{'combining color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='combine', virt_text_hide=true}) + api.nvim_buf_set_extmark(0, ns, 6, 5, { virt_text={{'replacing color', 'Blendy'}}, virt_text_pos='overlay', hl_mode='replace', virt_text_hide=true}) screen:expect{grid=[[ {5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | @@ -1152,8 +1208,7 @@ describe('extmark decorations', function() colpos {5:=} colpos{5:+}{13:1} | {5:end} | {5:end} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} @@ -1171,8 +1226,7 @@ describe('extmark decorations', function() colpos {5:=} colpos{5:+}{13:1} | {5:end} | {5:end} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {24:-- VISUAL LINE --} | ]]} @@ -1190,8 +1244,7 @@ describe('extmark decorations', function() colpos {5:=} colpos{5:+}{13:1} | {5:end} | {5:end} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {24:-- VISUAL LINE --} | ]]} end) @@ -1199,17 +1252,17 @@ describe('extmark decorations', function() it('can have virtual text of right_align and fixed win_col position', function() insert(example_text) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'Very', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text={{'VERY', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'Much', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 2, 10, { virt_text={{'MUCH', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'Error', 'ErrorMsg'}}, virt_text_win_col=31, hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 3, 14, { virt_text={{'ERROR', 'ErrorMsg'}}, virt_text_pos='right_align', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_win_col=4, hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 7, 21, { virt_text={{'-', 'NonText'}}, virt_text_pos='right_align', hl_mode='blend'}) -- empty virt_text should not change anything - meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'}) - meths.buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_pos='right_align', hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_win_col=14, hl_mode='blend'}) + api.nvim_buf_set_extmark(0, ns, 8, 0, { virt_text={{''}}, virt_text_pos='right_align', hl_mode='blend'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | @@ -1224,8 +1277,7 @@ describe('extmark decorations', function() colpos = colpos+1 | end | end | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} @@ -1262,8 +1314,7 @@ describe('extmark decorations', function() colpos = colpos+1 | end | end | - {1:~ }| - {1:~ }| + {1:~ }|*2 : | ]]} @@ -1305,7 +1356,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} }) + api.nvim_buf_set_extmark(0, ns, 4, 50, { virt_text={{'EOL', 'NonText'}} }) screen:expect{grid=[[ for _,item in ipairs(items) do | local text, hl_id_cell, cou{4:Very} unpack(ite{4:VERY}| @@ -1461,17 +1512,16 @@ describe('extmark decorations', function() it('virtual text win_col out of window does not break display #25645', function() screen:try_resize(51, 6) command('vnew') - meths.buf_set_lines(0, 0, -1, false, { string.rep('a', 50) }) + api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 50) }) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaa│ | aaaaaaaaaaaaaaaaaaaaaaaaa│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 {41:[No Name] [+] }{40:[No Name] }| | ]]} local extmark_opts = { virt_text_win_col = 35, virt_text = { { ' ', 'Comment' } } } - meths.buf_set_extmark(0, ns, 0, 0, extmark_opts) + api.nvim_buf_set_extmark(0, ns, 0, 0, extmark_opts) screen:expect_unchanged() assert_alive() end) @@ -1487,9 +1537,9 @@ describe('extmark decorations', function() -- XXX: the behavior of overlay virtual text at non-zero column is strange: -- 1. With 'wrap' it is never shown. -- 2. With 'nowrap' it is shown only if the extmark is hidden before leftcol. - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 5, { virt_text = {{'BB', 'Underlined'}}, hl_mode = 'combine', virt_text_win_col = 10 }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'CC', 'Underlined'}}, hl_mode = 'combine', virt_text_pos = 'right_align' }) screen:expect{grid=[[ {29:AA}{33:- 2 lin}{29:BB}{33:: 11111·····························}{29:CC}| 3333^3 | @@ -1532,9 +1582,9 @@ describe('extmark decorations', function() ddddd eeeee]]) command('windo diffthis') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'AA', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB', 'Underlined'}}, virt_text_win_col = 10 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CC', 'Underlined'}}, virt_text_pos = 'right_align' }) screen:expect{grid=[[ {37: }{38:aaaaa }│{37: }{39:------------------------}| {37: }bbbbb │{37: }{28:AA}bbb {28:BB} {28:CC}| @@ -1577,14 +1627,13 @@ describe('extmark decorations', function() {'d', {'BgTwo', 'FgZwei'}}; {'X', {'BgTwo', 'FgZwei', 'VeryBold'}}; } - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_lines = { vt, vt } }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'eol' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'right_align' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = vt, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines = { vt, vt } }) screen:expect{grid=[[ {2:a}{3:b}{4:c}{5:d}{6:X}#^# {2:a}{3:b}{4:c}{5:d}{6:X} {2:a}{3:b}{4:c}{5:d}{6:X}| - {2:a}{3:b}{4:c}{5:d}{6:X} | - {2:a}{3:b}{4:c}{5:d}{6:X} | + {2:a}{3:b}{4:c}{5:d}{6:X} |*2 {1:~ }| | ]]} @@ -1597,19 +1646,7 @@ describe('extmark decorations', function() ]] screen:expect{grid=[[ ^ a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*13 | ]]} @@ -1619,19 +1656,7 @@ describe('extmark decorations', function() ]] screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*13 | ]]} assert_alive() @@ -1640,43 +1665,40 @@ describe('extmark decorations', function() it('conceal with conceal char #19007', function() screen:try_resize(50, 5) insert('foo\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='X'}) command('set conceallevel=2') screen:expect([[ {26:X} | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) command('set conceallevel=1') screen:expect_unchanged() - eq("conceal char has to be printable", pcall_err(meths.buf_set_extmark, 0, ns, 0, 0, {end_col=0, end_row=2, conceal='\255'})) + eq("conceal char has to be printable", pcall_err(api.nvim_buf_set_extmark, 0, ns, 0, 0, {end_col=0, end_row=2, conceal='\255'})) end) it('conceal with composed conceal char', function() screen:try_resize(50, 5) insert('foo\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=0, end_row=2, conceal='ẍ̲'}) command('set conceallevel=2') screen:expect([[ {26:ẍ̲} | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) command('set conceallevel=1') screen:expect_unchanged() -- this is rare, but could happen. Save at least the first codepoint - meths._invalidate_glyph_cache() + api.nvim__invalidate_glyph_cache() screen:expect{grid=[[ {26:x} | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} end) @@ -1684,30 +1706,28 @@ describe('extmark decorations', function() it('conceal without conceal char #24782', function() screen:try_resize(50, 5) insert('foobar\n') - meths.buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_col=3, conceal=''}) command('set listchars=conceal:?') command('let &conceallevel=1') screen:expect([[ {26:?}bar | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) command('let &conceallevel=2') screen:expect([[ bar | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end) it('conceal works just before truncated double-width char #21486', function() screen:try_resize(40, 4) - meths.buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'}) - meths.buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''}) + api.nvim_buf_set_lines(0, 0, -1, true, {'', ('a'):rep(37) .. '<>古'}) + api.nvim_buf_set_extmark(0, ns, 1, 37, {end_col=39, conceal=''}) command('setlocal conceallevel=2') screen:expect{grid=[[ ^ | @@ -1724,6 +1744,35 @@ describe('extmark decorations', function() ]]} end) + it('redraws properly when adding/removing conceal on non-current line', function() + screen:try_resize(50, 5) + api.nvim_buf_set_lines(0, 0, -1, true, {'abcd', 'efgh','ijkl', 'mnop'}) + command('setlocal conceallevel=2') + screen:expect{grid=[[ + ^abcd | + efgh | + ijkl | + mnop | + | + ]]} + api.nvim_buf_set_extmark(0, ns, 2, 1, {end_col=3, conceal=''}) + screen:expect{grid=[[ + ^abcd | + efgh | + il | + mnop | + | + ]]} + api.nvim_buf_clear_namespace(0, ns, 0, -1) + screen:expect{grid=[[ + ^abcd | + efgh | + ijkl | + mnop | + | + ]]} + end) + it('avoids redraw issue #20651', function() exec_lua[[ vim.cmd.normal'10oXXX' @@ -1748,25 +1797,16 @@ describe('extmark decorations', function() ]] for _ = 1, 3 do - helpers.sleep(10) + vim.uv.sleep(10) feed 'j' end screen:expect{grid=[[ - {27: } | - XXX | - XXX | + {44: } | + XXX |*2 ^XXX HELLO | - XXX | - XXX | - XXX | - XXX | - XXX | - XXX | - XXX | - {1:~ }| - {1:~ }| - {1:~ }| + XXX |*7 + {1:~ }|*3 | ]]} @@ -1790,32 +1830,32 @@ describe('extmark decorations', function() [6] = {bold = true, undercurl = true, special = Screen.colors.Red}; }) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 20 }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 30 }) screen:expect([[ {1:aaa}{4:bbb}{1:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) + api.nvim_buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 20 }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 30 }) screen:expect([[ {2:aaa}{3:bbb}{2:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) + api.nvim_buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 30 }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUC', priority = 20 }) screen:expect([[ {1:aaa}{3:bbb}{1:aa^a} | {0:~ }| | ]]) - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) + api.nvim_buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 30 }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestUL', priority = 20 }) screen:expect([[ {2:aaa}{4:bbb}{2:aa^a} | {0:~ }| @@ -1824,14 +1864,14 @@ describe('extmark decorations', function() -- When only one highlight group has an underline attribute, it should always take effect. for _, d in ipairs({-5, 5}) do - meths.buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect([[ aaabbbaa^a | {0:~ }| | ]]) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUL', priority = 25 + d }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) screen:expect([[ {1:aaa}{5:bbb}{1:aa^a} | {0:~ }| @@ -1839,14 +1879,14 @@ describe('extmark decorations', function() ]]) end for _, d in ipairs({-5, 5}) do - meths.buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect([[ aaabbbaa^a | {0:~ }| | ]]) - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d }) - meths.buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 9, hl_group = 'TestUC', priority = 25 + d }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { end_col = 6, hl_group = 'TestBold', priority = 25 - d }) screen:expect([[ {2:aaa}{6:bbb}{2:aa^a} | {0:~ }| @@ -1863,10 +1903,11 @@ describe('extmark decorations', function() feed('gg') command('set ft=lua') command('syntax on') - meths.buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'Visual' }) + command('hi default MyMark guibg=LightGrey') + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_mode = 'combine', hl_group = 'MyMark' }) command('hi default MyLine gui=underline') command('sign define CurrentLine linehl=MyLine') - funcs.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 }) + fn.sign_place(6, 'Test', 'CurrentLine', '', { lnum = 1 }) screen:expect{grid=[[ {30:^fun}{31:ction}{32: Func() }| {6:end} | @@ -1877,8 +1918,8 @@ describe('extmark decorations', function() it('highlight works after TAB with sidescroll #14201', function() screen:try_resize(50, 3) command('set nowrap') - meths.buf_set_lines(0, 0, -1, true, {'\tword word word word'}) - meths.buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) + api.nvim_buf_set_lines(0, 0, -1, true, {'\tword word word word'}) + api.nvim_buf_set_extmark(0, ns, 0, 1, { end_col = 3, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^ {4:wo}rd word word word | {1:~ }| @@ -1906,16 +1947,16 @@ describe('extmark decorations', function() it('highlights the beginning of a TAB char correctly #23734', function() screen:try_resize(50, 3) - meths.buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) - meths.buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) + api.nvim_buf_set_lines(0, 0, -1, true, {'this is the\ttab'}) + api.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 15, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^this is the{4: tab} | {1:~ }| | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) - meths.buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' }) + api.nvim_buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_set_extmark(0, ns, 0, 12, { end_col = 15, hl_group = 'ErrorMsg' }) screen:expect{grid=[[ ^this is the {4:tab} | {1:~ }| @@ -1925,50 +1966,62 @@ describe('extmark decorations', function() it('highlight applies to a full TAB on line with matches #20885', function() screen:try_resize(50, 3) - meths.buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) - funcs.matchadd('Underlined', 'match') - meths.buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Visual' }) - meths.buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Visual' }) + api.nvim_buf_set_lines(0, 0, -1, true, {'\t-- match1', ' -- match2'}) + fn.matchadd('NonText', 'match') + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_row = 1, end_col = 0, hl_group = 'Search' }) + api.nvim_buf_set_extmark(0, ns, 1, 0, { end_row = 2, end_col = 0, hl_group = 'Search' }) screen:expect{grid=[[ - {18: ^ -- }{29:match}{18:1} | - {18: -- }{29:match}{18:2} | + {34: ^ -- }{35:match}{34:1} | + {34: -- }{35:match}{34:2} | | ]]} end) pending('highlight applies to a full TAB in visual block mode', function() screen:try_resize(50, 8) - meths.buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) - meths.buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) + command('hi! Visual guifg=NONE guibg=LightGrey') + api.nvim_buf_set_lines(0, 0, -1, true, {'asdf', '\tasdf', '\tasdf', '\tasdf', 'asdf'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 5, end_col = 0, hl_group = 'Underlined'}) screen:expect([[ {28:^asdf} | - {28: asdf} | - {28: asdf} | - {28: asdf} | + {28: asdf} |*3 {28:asdf} | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) feed('<C-V>Gll') screen:expect([[ {29:asd}{28:f} | - {29: }{28: asdf} | - {29: }{28: asdf} | - {29: }{28: asdf} | + {29: }{28: asdf} |*3 {29:as}{28:^df} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {24:-- VISUAL BLOCK --} | ]]) end) + it('highlight works properly with multibyte text and spell #26771', function() + insert('口口\n') + screen:try_resize(50, 3) + api.nvim_buf_set_extmark(0, ns, 0, 0, { end_col = 3, hl_group = 'Search' }) + screen:expect([[ + {34:口}口 | + ^ | + | + ]]) + command('setlocal spell') + screen:expect([[ + {43:口}{42:口} | + ^ | + | + ]]) + end) + it('supports multiline highlights', function() insert(example_text) feed 'gg' for _,i in ipairs {1,2,3,5,6,7} do for _,j in ipairs {2,5,10,15} do - meths.buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'}) + api.nvim_buf_set_extmark(0, ns, i, j, { end_col=j+2, hl_group = 'NonText'}) end end screen:expect{grid=[[ @@ -1984,8 +2037,7 @@ describe('extmark decorations', function() colpos = colpos+1 | end | end | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed'5<c-e>' @@ -1997,17 +2049,11 @@ describe('extmark decorations', function() colpos = colpos+1 | end | end | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 | ]]} - meths.buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'}) + api.nvim_buf_set_extmark(0, ns, 1, 0, { end_line=8, end_col=10, hl_group = 'ErrorMsg'}) screen:expect{grid=[[ {4:^ }{36: }{4:f}{36:or}{4: _ }{36:= }{4:1, }{36:(c}{4:ount or 1) do} | {4: }{36: }{4: }{36: }{4: lo}{36:ca}{4:l c}{36:el}{4:l = line[colpos]} | @@ -2016,13 +2062,7 @@ describe('extmark decorations', function() colpos = colpos+1 | end | end | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 | ]]} end) @@ -2031,7 +2071,7 @@ describe('extmark decorations', function() screen:try_resize(50, 5) insert(example_text) feed'gg' - meths.buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val}) + api.nvim_buf_set_extmark(0, ns, 0, 6, { end_col=13, hl_group = 'NonText', undo_restore=val}) screen:expect{grid=[[ ^for _,{1:item in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | @@ -2040,7 +2080,7 @@ describe('extmark decorations', function() | ]]} - meths.buf_set_text(0, 0, 4, 0, 8, {''}) + api.nvim_buf_set_text(0, 0, 4, 0, 8, {''}) screen:expect{grid=[[ ^for {1:em in} ipairs(items) do | local text, hl_id_cell, count = unpack(item) | @@ -2078,7 +2118,7 @@ describe('extmark decorations', function() eq({ { 1, 0, 8, { end_col = 13, end_right_gravity = false, end_row = 0, hl_eol = false, hl_group = "NonText", undo_restore = false, ns_id = 1, priority = 4096, right_gravity = true } } }, - meths.buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) + api.nvim_buf_get_extmarks(0, ns, {0,0}, {0, -1}, {details=true})) end) it('virtual text works with rightleft', function() @@ -2086,10 +2126,10 @@ describe('extmark decorations', function() insert('abcdefghijklmn') feed('0') command('set rightleft') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}}) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'EOL', 'Underlined'}}}) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'right_align', 'Underlined'}}, virt_text_pos = 'right_align' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'win_col', 'Underlined'}}, virt_text_win_col = 20 }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) screen:expect{grid=[[ {28:ngila_thgir} {28:loc_niw} {28:LOE} nml{28:deyalrevo}b^a| {1: ~}| @@ -2135,7 +2175,74 @@ describe('extmark decorations', function() ]]} end) - it('works with double width char and rightleft', function() + it('virtual text overwrites double-width char properly', function() + screen:try_resize(50, 3) + insert('abcdefghij口klmnopqrstu口vwx口yz') + feed('0') + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'!!!!!', 'Underlined'}}, virt_text_win_col = 11 }) + screen:expect{grid=[[ + ^abcdefghij {28:!!!!!}opqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('8x') + screen:expect{grid=[[ + ^ij口klmnopq{28:!!!!!} vwx口yz | + {1:~ }| + | + ]]} + feed('3l5x') + screen:expect{grid=[[ + ij口^pqrstu {28:!!!!!} yz | + {1:~ }| + | + ]]} + feed('5x') + screen:expect{grid=[[ + ij口^u口vwx {28:!!!!!} | + {1:~ }| + | + ]]} + end) + + it('virtual text blending space does not overwrite double-width char', function() + screen:try_resize(50, 3) + insert('abcdefghij口klmnopqrstu口vwx口yz') + feed('0') + command('hi Blendy guibg=Red blend=30') + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{' ! ! ', 'Blendy'}}, virt_text_win_col = 8, hl_mode = 'blend' }) + screen:expect{grid=[[ + ^abcdefgh{10:i}{7:!}{10:口}{7:!}{10:l}mnopqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^bcdefghi{10:j}{7:!}{10: k}{7:!}{10:m}nopqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^cdefghij{10: }{7:!}{10:kl}{7:!}{10:n}opqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('x') + screen:expect{grid=[[ + ^defghij口{7:!}{10:lm}{7:!}{10:o}pqrstu口vwx口yz | + {1:~ }| + | + ]]} + feed('7x') + screen:expect{grid=[[ + ^口klmnop{10:q}{7:!}{10:st}{7:!}{10:口}vwx口yz | + {1:~ }| + | + ]]} + end) + + it('virtual text works with double-width char and rightleft', function() screen:try_resize(50, 3) insert('abcdefghij口klmnopqrstu口vwx口yz') feed('0') @@ -2145,10 +2252,10 @@ describe('extmark decorations', function() {1: ~}| | ]]} - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' }) - meths.buf_set_extmark(0, ns, 0, 29, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = {{'overlayed', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 14, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 20, { virt_text = {{'\t', 'Underlined'}}, virt_text_pos = 'overlay' }) + api.nvim_buf_set_extmark(0, ns, 0, 29, { virt_text = {{'古', 'Underlined'}}, virt_text_pos = 'overlay' }) screen:expect{grid=[[ zy {28:古}wv {28: }qpon{28:古}k {28:deyalrevo}b^a| {1: ~}| @@ -2156,16 +2263,231 @@ describe('extmark decorations', function() ]]} end) + it('virtual text is drawn correctly after delete and undo #27368', function() + insert('aaa\nbbb\nccc\nddd\neee') + command('vsplit') + api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{'EOL'}} }) + feed('3gg') + screen:expect{grid=[[ + aaa │aaa | + bbb │bbb | + ^ccc EOL │ccc EOL | + ddd │ddd | + eee │eee | + {1:~ }│{1:~ }|*8 + {41:[No Name] [+] }{40:[No Name] [+] }| + | + ]]} + feed('dd') + screen:expect{grid=[[ + aaa │aaa | + bbb │bbb | + ^ddd EOL │ddd EOL | + eee │eee | + {1:~ }│{1:~ }|*9 + {41:[No Name] [+] }{40:[No Name] [+] }| + | + ]]} + command('silent undo') + screen:expect{grid=[[ + aaa │aaa | + bbb │bbb | + ^ccc EOL │ccc EOL | + ddd │ddd | + eee │eee | + {1:~ }│{1:~ }|*8 + {41:[No Name] [+] }{40:[No Name] [+] }| + | + ]]} + end) + it('works with both hl_group and sign_hl_group', function() screen:try_resize(screen._width, 3) insert('abcdefghijklmn') - meths.buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S', sign_hl_group='NonText', hl_group='Error', end_col=14}) screen:expect{grid=[[ {1:S }{4:abcdefghijklm^n} | {1:~ }| | ]]} end) + + it('virt_text_repeat_linebreak repeats virtual text on wrapped lines', function() + screen:try_resize(40, 5) + api.nvim_set_option_value('breakindent', true, {}) + insert(example_text) + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) + api.nvim_buf_set_extmark(0, ns, 1, 3, { virt_text = {{'│', 'NonText'}}, virt_text_pos = 'overlay', virt_text_repeat_linebreak = true }) + command('norm gg') + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + {1:│} {1:│}local text, hl_id_cell, count = unpa| + {1:│} {1:│}ck(item) | + if hl_id_cell ~= nil then | + | + ]]} + api.nvim_buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 0 }) + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_text = {{'│', 'NonText'}}, virt_text_repeat_linebreak = true, virt_text_win_col = 2 }) + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + {1:│} {1:│} local text, hl_id_cell, count = unpa| + {1:│} {1:│} ck(item) | + if hl_id_cell ~= nil then | + | + ]]} + end) + + it('supports URLs', function() + insert(example_text) + + local url = 'https://example.com' + + screen:set_default_attr_ids({ + e = { bold = true, foreground = Screen.colors.Blue }, + u = { url = url }, + }) + + api.nvim_buf_set_extmark(0, ns, 1, 4, { + end_col = 14, + url = url, + }) + + screen:expect{grid=[[ + for _,item in ipairs(items) do | + {u:local text}, hl_id_cell, count = unpack(item) | + if hl_id_cell ~= nil then | + hl_id = hl_id_cell | + end | + for _ = 1, (count or 1) do | + local cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+1 | + end | + en^d | + {e:~ }| + {e:~ }| + | + ]]} + end) + + it('can replace marks in place with different decorations #27211', function() + local mark = api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines = {{{"foo", "ErrorMsg"}}}, }) + screen:expect{grid=[[ + ^ | + {4:foo} | + {1:~ }|*12 + | + ]]} + + api.nvim_buf_set_extmark(0, ns, 0, 0, { + id = mark, + virt_text = { { "testing", "NonText" } }, + virt_text_pos = "inline", + }) + screen:expect{grid=[[ + {1:^testing} | + {1:~ }|*13 + | + ]]} + + api.nvim_buf_del_extmark(0, ns, mark) + screen:expect{grid=[[ + ^ | + {1:~ }|*13 + | + ]]} + + helpers.assert_alive() + end) + + it('priority ordering of overlay or win_col virtual text at same position', function() + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'A'}}, virt_text_pos = 'overlay', priority = 100 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'A'}}, virt_text_win_col = 30, priority = 100 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB'}}, virt_text_pos = 'overlay', priority = 90 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'BB'}}, virt_text_win_col = 30, priority = 90 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CCC'}}, virt_text_pos = 'overlay', priority = 80 }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'CCC'}}, virt_text_win_col = 30, priority = 80 }) + screen:expect([[ + ^ABC ABC | + {1:~ }|*13 + | + ]]) + end) + + it('priority ordering of inline and non-inline virtual text at same char', function() + insert(('?'):rep(40) .. ('!'):rep(30)) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'A'}}, virt_text_pos = 'overlay', priority = 10 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'a'}}, virt_text_win_col = 15, priority = 10 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'BBBB'}}, virt_text_pos = 'inline', priority = 15 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'C'}}, virt_text_pos = 'overlay', priority = 20 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'c'}}, virt_text_win_col = 17, priority = 20 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'DDDD'}}, virt_text_pos = 'inline', priority = 25 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'E'}}, virt_text_pos = 'overlay', priority = 30 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'e'}}, virt_text_win_col = 19, priority = 30 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'FFFF'}}, virt_text_pos = 'inline', priority = 35 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'G'}}, virt_text_pos = 'overlay', priority = 40 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'g'}}, virt_text_win_col = 21, priority = 40 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'HHHH'}}, virt_text_pos = 'inline', priority = 45 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'I'}}, virt_text_pos = 'overlay', priority = 50 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'i'}}, virt_text_win_col = 23, priority = 50 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'JJJJ'}}, virt_text_pos = 'inline', priority = 55 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'K'}}, virt_text_pos = 'overlay', priority = 60 }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = {{'k'}}, virt_text_win_col = 25, priority = 60 }) + screen:expect([[ + ???????????????a?c?e????????????????????ABBBCDDDEF| + FFGHHHIJJJK!!!!!!!!!!g!i!k!!!!!!!!!!!!!^! | + {1:~ }|*12 + | + ]]) + feed('02x$') + screen:expect([[ + ???????????????a?c?e??????????????????ABBBCDDDEFFF| + GHHHIJJJK!!!!!!!!!!!!g!i!k!!!!!!!!!!!^! | + {1:~ }|*12 + | + ]]) + feed('02x$') + screen:expect([[ + ???????????????a?c?e?g??????????????ABBBCDDDEFFFGH| + HHIJJJK!!!!!!!!!!!!!!!!i!k!!!!!!!!!^! | + {1:~ }|*12 + | + ]]) + feed('02x$') + screen:expect([[ + ???????????????a?c?e?g????????????ABBBCDDDEFFFGHHH| + IJJJK!!!!!!!!!!!!!!!!!!i!k!!!!!!!^! | + {1:~ }|*12 + | + ]]) + command('set nowrap') + feed('0') + screen:expect([[ + ^???????????????a?c?e?g?i?k????????ABBBCDDDEFFFGHHH| + {1:~ }|*13 + | + ]]) + feed('2x') + screen:expect([[ + ^???????????????a?c?e?g?i?k??????ABBBCDDDEFFFGHHHIJ| + {1:~ }|*13 + | + ]]) + feed('2x') + screen:expect([[ + ^???????????????a?c?e?g?i?k????ABBBCDDDEFFFGHHHIJJJ| + {1:~ }|*13 + | + ]]) + feed('2x') + screen:expect([[ + ^???????????????a?c?e?g?i?k??ABBBCDDDEFFFGHHHIJJJK!| + {1:~ }|*13 + | + ]]) + end) end) describe('decorations: inline virtual text', function() @@ -2181,7 +2503,7 @@ describe('decorations: inline virtual text', function() [4] = {background = Screen.colors.Red1, foreground = Screen.colors.Gray100}; [5] = {background = Screen.colors.Red1, bold = true}; [6] = {foreground = Screen.colors.DarkCyan}; - [7] = {background = Screen.colors.LightGrey}; + [7] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Black}; [8] = {bold = true}; [9] = {background = Screen.colors.Plum1}; [10] = {foreground = Screen.colors.SlateBlue}; @@ -2198,7 +2520,7 @@ describe('decorations: inline virtual text', function() [21] = {reverse = true, foreground = Screen.colors.SlateBlue} } - ns = meths.create_namespace 'test' + ns = api.nvim_create_namespace 'test' end) @@ -2219,7 +2541,7 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) + api.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{': ', 'Special'}, {'string', 'Type'}}, virt_text_pos='inline'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | local text{10:: }{3:string}, hl_id_cell, count = unpack| @@ -2279,9 +2601,9 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'}) - meths.buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'}) + api.nvim_buf_set_extmark(0, ns, 0, 5, {virt_text={{''}, {''}}, virt_text_pos='inline'}) + api.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {': ', 'Special'}}, virt_text_pos='inline'}) + api.nvim_buf_set_extmark(0, ns, 1, 48, {virt_text={{''}, {''}}, virt_text_pos='inline'}) screen:expect{grid=[[ ^for _,item in ipairs(items) do | local text{10:: }, hl_id_cell, count = unpack(item)| @@ -2295,7 +2617,7 @@ describe('decorations: inline virtual text', function() | ]]} - meths.buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'}) + api.nvim_buf_set_extmark(0, ns, 1, 14, {virt_text={{''}, {'string', 'Type'}}, virt_text_pos='inline'}) feed('V') screen:expect{grid=[[ ^f{7:or _,item in ipairs(items) do} | @@ -2327,8 +2649,8 @@ describe('decorations: inline virtual text', function() it('Normal mode "gM" command works properly', function() command([[call setline(1, '123456789')]]) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 7, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 7, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) feed('gM') screen:expect{grid=[[ 12{10:bbb}34^567{10:bbb}89 | @@ -2340,8 +2662,8 @@ describe('decorations: inline virtual text', function() local function test_normal_gj_gk() screen:try_resize(60, 6) command([[call setline(1, repeat([repeat('a', 55)], 2))]]) - meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 1, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 1, 40, { virt_text = { { ('b'):rep(10), 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa{10:bbbbbbbbbb}aaaaaaaaaa| aaaaa | @@ -2419,8 +2741,8 @@ describe('decorations: inline virtual text', function() it('cursor positions are correct with multiple inline virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '4l' screen:expect{grid=[[ @@ -2433,7 +2755,7 @@ describe('decorations: inline virtual text', function() it('adjusts cursor location correctly when inserting around inline virtual text', function() insert('12345678') feed '$' - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { ' virtual text ', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ 1234{10: virtual text }567^8 | @@ -2444,7 +2766,7 @@ describe('decorations: inline virtual text', function() it('has correct highlighting with multi-byte characters', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'múlti-byté chñröcters 修补', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ 1234{10:múlti-byté chñröcters 修补}567^8 | @@ -2455,7 +2777,7 @@ describe('decorations: inline virtual text', function() it('has correct cursor position when inserting around virtual text', function() insert('12345678') - meths.buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed '^' feed '3l' feed 'a' @@ -2481,7 +2803,7 @@ describe('decorations: inline virtual text', function() end) it('has correct cursor position with virtual text on an empty line', function() - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ {10:^virtual text} | {1:~ }| @@ -2495,8 +2817,8 @@ describe('decorations: inline virtual text', function() call setline(1, ['', 'aaa', '', 'bbbbbb']) normal gg0 ]]) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 61), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('X', 60), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = { { string.rep('X', 61), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -2504,8 +2826,7 @@ describe('decorations: inline virtual text', function() {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('j') @@ -2515,8 +2836,7 @@ describe('decorations: inline virtual text', function() {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('j') @@ -2526,8 +2846,7 @@ describe('decorations: inline virtual text', function() {10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('j') @@ -2537,8 +2856,7 @@ describe('decorations: inline virtual text', function() {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | bbbbb^b | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('0<C-V>2l2k') @@ -2548,8 +2866,7 @@ describe('decorations: inline virtual text', function() {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | {7:bbb}bbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 {8:-- VISUAL BLOCK --} | ]]} feed([[<Esc>/aaa\n\%V<CR>]]) @@ -2559,8 +2876,7 @@ describe('decorations: inline virtual text', function() {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:X} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 {16:search hit BOTTOM, continuing at TOP} | ]]} feed('3ggic') @@ -2570,8 +2886,7 @@ describe('decorations: inline virtual text', function() c{10:^XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XX} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 {8:-- INSERT --} | ]]} feed([[<Esc>/aaa\nc\%V<CR>]]) @@ -2581,8 +2896,7 @@ describe('decorations: inline virtual text', function() {12:c}{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| {10:XX} | bbbbbb | - {1:~ }| - {1:~ }| + {1:~ }|*2 {16:search hit BOTTOM, continuing at TOP} | ]]} end) @@ -2594,7 +2908,7 @@ describe('decorations: inline virtual text', function() feed('<TAB>') feed('test') feed('<ESC>') - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('0') screen:expect{grid=[[ ^ {10:virtual text} test | @@ -2635,7 +2949,7 @@ describe('decorations: inline virtual text', function() command('set linebreak') insert('one twoword') feed('0') - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ': virtual text', 'Special' } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ ^one{10:: virtual text} twoword | {1:~ }| @@ -2646,10 +2960,10 @@ describe('decorations: inline virtual text', function() it('search highlight is correct', function() insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') - meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 9, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 9, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) screen:expect{grid=[[ ^foo foo f{10:AAABBB}oo bar | foo foo f{10:CCCDDD}oo bar | @@ -2663,7 +2977,7 @@ describe('decorations: inline virtual text', function() /foo^ | ]]} - meths.buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 0, 13, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('<C-G>') screen:expect{grid=[[ {12:foo} {12:foo} {13:f}{10:AAA}{21:BBB}{13:oo} b{10:EEE}ar | @@ -2675,10 +2989,10 @@ describe('decorations: inline virtual text', function() it('Visual select highlight is correct', function() insert('foo foo foo bar\nfoo foo foo bar') feed('gg0') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('8l') screen:expect{grid=[[ foo foo {10:AAABBB}^foo bar | @@ -2694,7 +3008,7 @@ describe('decorations: inline virtual text', function() {8:-- VISUAL BLOCK --} | ]]} - meths.buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 0, 10, { virt_text = { { 'EEE', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) screen:expect{grid=[[ foo fo{7:o }{10:AAA}{20:BBB}{7:f}o{10:EEE}o bar | foo fo^o{7: }{20:CCC}{10:DDD}{7:f}oo bar | @@ -2704,12 +3018,12 @@ describe('decorations: inline virtual text', function() it('inside highlight range of another extmark', function() insert('foo foo foo bar\nfoo foo foo bar') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - meths.buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) - meths.buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 0, 4, { end_col = 11, hl_group = 'Search' }) + api.nvim_buf_set_extmark(0, ns, 1, 4, { end_col = 11, hl_group = 'Search' }) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | foo {12:foo }{19:CCC}{10:DDD}{12:foo} ba^r | @@ -2719,10 +3033,10 @@ describe('decorations: inline virtual text', function() it('inside highlight range of syntax', function() insert('foo foo foo bar\nfoo foo foo bar') - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'AAA', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { 'BBB', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'CCC', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { virt_text = { { 'DDD', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) command([[syntax match Search 'foo \zsfoo foo\ze bar']]) screen:expect{grid=[[ foo {12:foo }{10:AAA}{19:BBB}{12:foo} bar | @@ -2734,7 +3048,7 @@ describe('decorations: inline virtual text', function() it('cursor position is correct when inserting around a virtual text with left gravity', function() screen:try_resize(27, 4) insert(('a'):rep(15)) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = { { ('>'):rep(43), 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) command('setlocal showbreak=+ breakindent breakindentopt=shift:2') feed('08l') screen:expect{grid=[[ @@ -2805,8 +3119,8 @@ describe('decorations: inline virtual text', function() screen:try_resize(30, 4) command('setlocal showbreak=+ breakindent breakindentopt=shift:2') insert(('a'):rep(15)) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) - meths.buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('>'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = false }) + api.nvim_buf_set_extmark(0, ns, 0, 8, { virt_text = {{ ('<'):rep(32), 'Special' }}, virt_text_pos = 'inline', right_gravity = true }) feed('08l') screen:expect{grid=[[ aaaaaaaa{10:>>>>>>>>>>>>>>>>>>>>>>}| @@ -2903,8 +3217,8 @@ describe('decorations: inline virtual text', function() it('draws correctly with no wrap multiple virtual text, where one is hidden', function() insert('abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ opqrstuvwxyzabcdefghijklmnopqrstuvwx{10:virtual text}y^z| @@ -2916,7 +3230,7 @@ describe('decorations: inline virtual text', function() it('draws correctly with no wrap and a long virtual text', function() insert('abcdefghi') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}cdefgh^i| @@ -2928,7 +3242,7 @@ describe('decorations: inline virtual text', function() it('tabs are the correct length with no wrap following virtual text', function() command('set nowrap') feed('itest<TAB>a<ESC>') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg$') screen:expect{grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaaaaa}test ^a | @@ -2940,7 +3254,7 @@ describe('decorations: inline virtual text', function() it('highlighting does not extend with no wrap and a long virtual text', function() insert('abcdef') command("set nowrap") - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 50), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}de^f| @@ -2952,7 +3266,7 @@ describe('decorations: inline virtual text', function() it('hidden virtual text does not interfere with Visual highlight', function() insert('abcdef') command('set nowrap') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'XXX', 'Special' } }, virt_text_pos = 'inline' }) feed('V2zl') screen:expect{grid=[[ {10:X}{7:abcde}^f | @@ -2979,7 +3293,7 @@ describe('decorations: inline virtual text', function() test test]]) command('set number') - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') screen:expect{grid=[[ {2: 1 }^t{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -2992,7 +3306,7 @@ describe('decorations: inline virtual text', function() it('highlighting is correct when virtual text is proceeded with a match', function() insert([[test]]) - meths.buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 2, { virt_text = { { 'virtual text', 'Special' } }, virt_text_pos = 'inline' }) feed('gg0') command('match ErrorMsg /e/') screen:expect{grid=[[ @@ -3010,7 +3324,7 @@ describe('decorations: inline virtual text', function() it('smoothscroll works correctly when virtual text wraps', function() insert('foobar') - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { string.rep('X', 55), 'Special' } }, virt_text_pos = 'inline' }) command('setlocal smoothscroll') screen:expect{grid=[[ foo{10:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}| @@ -3036,9 +3350,9 @@ describe('decorations: inline virtual text', function() ]]) insert('aaa\tbbb') command("set diff") - meths.buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) - meths.buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 1, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline', right_gravity = false }) + api.nvim_buf_set_extmark(0, ns, 5, 0, { virt_text = { { '!', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 5, 3, { virt_text = { { '' } }, virt_text_pos = 'inline' }) command("vnew") insert([[ 000 @@ -3052,13 +3366,11 @@ describe('decorations: inline virtual text', function() feed('gg0') screen:expect{grid=[[ {9:^000 }│{5:9}{14:test}{9:000 }| - {9:000 }│{9:000}{5:9}{9: }| - {9:000 }│{9:000}{5:9}{9: }| + {9:000 }│{9:000}{5:9}{9: }|*2 {9:000 }│{5:9}{9:000 }| {9:000 }│{9:000}{5:9}{9: }| {9:aaabbb }│{14:!}{9:aaa}{5: }{9:bbb }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 {15:[No Name] [+] }{13:[No Name] [+] }| | ]]} @@ -3066,13 +3378,11 @@ describe('decorations: inline virtual text', function() feed('zl') screen:expect{grid=[[ {9:000 }│{14:test}{9:000 }| - {9:000 }│{9:00}{5:9}{9: }| - {9:000 }│{9:00}{5:9}{9: }| + {9:000 }│{9:00}{5:9}{9: }|*2 {9:000 }│{9:000 }| {9:000 }│{9:00}{5:9}{9: }| {9:aaabbb }│{9:aaa}{5: }{9:bb^b }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 {13:[No Name] [+] }{15:[No Name] [+] }| | ]]} @@ -3081,8 +3391,8 @@ describe('decorations: inline virtual text', function() it('correctly draws when there are multiple overlapping virtual texts on the same line with nowrap', function() command('set nowrap') insert('a') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('a', 55), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { string.rep('b', 55), 'Special' } }, virt_text_pos = 'inline' }) feed('$') screen:expect{grid=[[ {10:bbbbbbbbbbbbbbbbbbbbbbbbb}^a | @@ -3094,7 +3404,7 @@ describe('decorations: inline virtual text', function() it('correctly draws when overflowing virtual text is followed by TAB with no wrap', function() command('set nowrap') feed('i<TAB>test<ESC>') - meths.buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark( 0, ns, 0, 0, { virt_text = { { string.rep('a', 60), 'Special' } }, virt_text_pos = 'inline' }) feed('0') screen:expect({grid=[[ {10:aaaaaaaaaaaaaaaaaaaaaa} ^ test | @@ -3112,8 +3422,8 @@ describe('decorations: inline virtual text', function() bbbbb ccccc]]) - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = {{'foo'}}, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{'bar'}}, virt_text_pos = 'inline' }) screen:expect{grid=[[ fooaaaaa | bbbbb | @@ -3141,44 +3451,37 @@ describe('decorations: inline virtual text', function() screen:expect{grid=[[ {18:^+-- 2 lines: aaaaa·······························································}| {17:+-- 2 lines: ccccc·······························································}| - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('j') screen:expect{grid=[[ {17:+-- 2 lines: aaaaa·······························································}| {18:^+-- 2 lines: ccccc·······························································}| - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} end) it('does not crash at right edge of wide window #23848', function() screen:try_resize(82, 5) - meths.buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_text = {{('a'):rep(82)}, {'b'}}, virt_text_pos = 'inline'}) screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| b | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} command('set nowrap') screen:expect{grid=[[ ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed('82i0<Esc>0') screen:expect{grid=[[ ^0000000000000000000000000000000000000000000000000000000000000000000000000000000000| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} command('set wrap') @@ -3196,7 +3499,7 @@ describe('decorations: inline virtual text', function() setlocal nowrap list listchars=extends:! call setline(1, repeat('a', 51)) ]]) - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { 'bbb', 'Special' } }, virt_text_pos = 'inline' }) feed('20l') screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaa^aaaaaaaaaaaaaaaaaaaaaaaaaaaaa{1:!}| @@ -3233,7 +3536,7 @@ describe('decorations: inline virtual text', function() command('set nowrap') command('set list') command('set listchars+=extends:c') - meths.buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_text = { { 'test', 'Special' } }, virt_text_pos = 'inline' }) insert(string.rep('a', 50)) feed('gg0') screen:expect{grid=[[ @@ -3246,8 +3549,8 @@ describe('decorations: inline virtual text', function() it('blockwise Visual highlight with double-width virtual text (replace)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) - meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) + api.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'replace' }) feed('gg0') screen:expect{grid=[[ ^123456789 | @@ -3316,8 +3619,8 @@ describe('decorations: inline virtual text', function() it('blockwise Visual highlight with double-width virtual text (combine)', function() screen:try_resize(60, 6) insert('123456789\n123456789\n123456789\n123456789') - meths.buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) - meths.buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 1, 1, { virt_text = { { '-口-', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) + api.nvim_buf_set_extmark(0, ns, 2, 2, { virt_text = { { '口', 'Special' } }, virt_text_pos = 'inline', hl_mode = 'combine' }) feed('gg0') screen:expect{grid=[[ ^123456789 | @@ -3392,7 +3695,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 28)) normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 27, { virt_text = { { ('123'):rep(23) } }, virt_text_pos = 'inline' }) feed(':<CR>') -- Have a screen line that doesn't start with spaces screen:expect{grid=[[ 1 aaaaaaaaaaaaaaaaaaaaaaaaaa| @@ -3416,26 +3719,20 @@ describe('decorations: inline virtual text', function() {1:+}23123123123123123123123| {1:+}12312312312312312312312| {1:+}3^a | - {1:~ }| - {1:~ }| + {1:~ }|*2 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}12312312312312312312312| {1:+}3^a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}3^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 : | ]]} feed('zbi') @@ -3480,26 +3777,20 @@ describe('decorations: inline virtual text', function() {1:+}31231231231231231231231| {1:+}23123123123123123123123| {1:+}^a | - {1:~ }| - {1:~ }| + {1:~ }|*2 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}23123123123123123123123| {1:+}^a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 : | ]]} feed('023x$') @@ -3516,26 +3807,20 @@ describe('decorations: inline virtual text', function() {1:+}31231231231231231231231| {1:+}23123123123123123123123| {1:+}^a | - {1:~ }| - {1:~ }| + {1:~ }|*2 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}23123123123123123123123| {1:+}^a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 : | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 : | ]]} feed('zbi') @@ -3552,8 +3837,7 @@ describe('decorations: inline virtual text', function() 1 ^12312312312312312312312312| {1:+}31231231231231231231231| {1:+}23123123123123123123a | - {1:~ }| - {1:~ }| + {1:~ }|*2 {8:-- INSERT --} | ]]} feed('<Esc>') @@ -3561,26 +3845,20 @@ describe('decorations: inline virtual text', function() 1 12312312312312312312312312| {1:+}31231231231231231231231| {1:+}23123123123123123123^a | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}31231231231231231231231| {1:+}23123123123123123123^a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:+}23123123123123123123^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]} feed('zbx') @@ -3588,8 +3866,7 @@ describe('decorations: inline virtual text', function() 1 ^12312312312312312312312312| {1:+}31231231231231231231231| {1:+}23123123123123123123 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('26ia<Esc>a') @@ -3631,7 +3908,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat("\t", 4) .. 'a') normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 3, { virt_text = { { ('12'):rep(32) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ {1:<------><------><------>}121212| 121212121212121212121212121212| @@ -3645,26 +3922,20 @@ describe('decorations: inline virtual text', function() {1:<<<}212121212121212121212121212| 1212121212121212121212121212{1:<-}| {1:----->}^a | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:<<<}2121212121212121212121212{1:<-}| {1:----->}^a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:<<<-->}^a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]} feed('zbh') @@ -3708,26 +3979,20 @@ describe('decorations: inline virtual text', function() {1:<<<}212121212121212121212121212| 1212121212121212121212121212 | ^ a | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:<<<}2121212121212121212121212 | ^ a | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed('<C-E>') screen:expect{grid=[[ {1:<<<} ^ a | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]} end) @@ -3739,13 +4004,12 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 50) .. ' ' .. repeat('c', 45)) normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 50, { virt_text = { { ('b'):rep(10) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:+}bbbbbbbbbb | {1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} feed('05x$') @@ -3753,8 +4017,7 @@ describe('decorations: inline virtual text', function() aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbb| {1:+}bbbbb | {1:+}cccccccccccccccccccccccccccccccccccccccccccc^c | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} end) @@ -3764,7 +4027,7 @@ describe('decorations: inline virtual text', function() call setline(1, repeat('a', 40) .. '口' .. '12345') normal! $ ]]) - meths.buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' }) + api.nvim_buf_set_extmark(0, ns, 0, 40, { virt_text = { { ('b'):rep(9) } }, virt_text_pos = 'inline' }) screen:expect{grid=[[ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbb{1:>}| 口1234^5 | @@ -3791,7 +4054,7 @@ describe('decorations: virtual lines', function() [9] = {foreground = Screen.colors.Brown}; } - ns = meths.create_namespace 'test' + ns = api.nvim_create_namespace 'test' end) local example_text2 = [[ @@ -3806,16 +4069,31 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with one line', function() insert(example_text2) - feed 'gg' - meths.buf_set_extmark(0, ns, 1, 33, { + feed '2gg' + screen:expect{grid=[[ + if (h->n_buckets < new_n_buckets) { // expand | + ^khkey_t *new_keys = (khkey_t *)krealloc((void *)| + h->keys, new_n_buckets * sizeof(khkey_t)); | + h->keys = new_keys; | + if (kh_is_map && val_size) { | + char *new_vals = krealloc( h->vals_buf, new_n_| + buckets * val_size); | + h->vals_buf = new_vals; | + } | + } | + {1:~ }| + | + ]]} + + api.nvim_buf_set_extmark(0, ns, 1, 33, { virt_lines={ {{">> ", "NonText"}, {"krealloc", "Identifier"}, {": change the size of an allocation"}}}; virt_lines_above=true; }) screen:expect{grid=[[ - ^if (h->n_buckets < new_n_buckets) { // expand | + if (h->n_buckets < new_n_buckets) { // expand | {1:>> }{2:krealloc}: change the size of an allocation | - khkey_t *new_keys = (khkey_t *)krealloc((void *)| + ^khkey_t *new_keys = (khkey_t *)krealloc((void *)| h->keys, new_n_buckets * sizeof(khkey_t)); | h->keys = new_keys; | if (kh_is_map && val_size) { | @@ -3876,10 +4154,9 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 5, 0, { + api.nvim_buf_set_extmark(0, ns, 5, 0, { virt_lines = { {{"^^ REVIEW:", "Todo"}, {" new_vals variable seems unnecessary?", "Comment"}} }; }) - -- TODO: what about the cursor?? screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | khkey_t *new_keys = (khkey_t *) | @@ -3895,8 +4172,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) - -- Cursor should be drawn on the correct line. #22704 + api.nvim_buf_clear_namespace(0, ns, 0, -1) screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | khkey_t *new_keys = (khkey_t *) | @@ -3932,7 +4208,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 0, 0, { + api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines={ {{"refactor(khash): ", "Special"}, {"take size of values as parameter"}}; {{"Author: Dev Devsson, "}, {"Tue Aug 31 10:13:37 2021", "Comment"}}; @@ -3993,7 +4269,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local id = meths.buf_set_extmark(0, ns, 7, 0, { + local id = api.nvim_buf_set_extmark(0, ns, 7, 0, { virt_lines={{{"Grugg"}}}; right_gravity=false; }) @@ -4076,7 +4352,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_del_extmark(0, ns, id) + api.nvim_buf_del_extmark(0, ns, id) screen:expect{grid=[[ if (h->n_buckets < new_n_buckets) { // expand | khkey_t *new_keys = (khkey_t *)krealloc((void *)| @@ -4112,7 +4388,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local id = meths.buf_set_extmark(0, ns, 8, 0, { + local id = api.nvim_buf_set_extmark(0, ns, 8, 0, { virt_lines={{{"Grugg"}}}; virt_lines_above = true, }) @@ -4158,9 +4434,7 @@ if (h->n_buckets < new_n_buckets) { // expand ^char *new_vals = krealloc( h->vals_buf, new_n_| buckets * val_size); | Grugg | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -4168,31 +4442,14 @@ if (h->n_buckets < new_n_buckets) { // expand screen:expect{grid=[[ ^ | Grugg | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*9 --No lines in buffer-- | ]]} - meths.buf_del_extmark(0, ns, id) + api.nvim_buf_del_extmark(0, ns, id) screen:expect{grid=[[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 --No lines in buffer-- | ]]} end) @@ -4201,19 +4458,11 @@ if (h->n_buckets < new_n_buckets) { // expand command([[syntax region foo keepend start='^foo' end='^$']]) command('syntax sync minlines=100') insert('foo') - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'bar', 'Comment'}}}}) screen:expect([[ fo^o | {6:bar} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*9 | ]]) end) @@ -4223,7 +4472,7 @@ if (h->n_buckets < new_n_buckets) { // expand insert("aa\nbb\ncc\ndd\nee\nff\ngg\nhh") feed 'gg' - meths.buf_set_extmark(0, ns, 6, 0, { + api.nvim_buf_set_extmark(0, ns, 6, 0, { virt_lines={ {{"they see me"}}; {{"scrolling", "Special"}}; @@ -4325,8 +4574,7 @@ if (h->n_buckets < new_n_buckets) { // expand they | {7:hatin'} | ^hh | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} @@ -4335,9 +4583,7 @@ if (h->n_buckets < new_n_buckets) { // expand they | {7:hatin'} | ^hh | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} @@ -4345,21 +4591,14 @@ if (h->n_buckets < new_n_buckets) { // expand screen:expect{grid=[[ {7:hatin'} | ^hh | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]} feed '<c-e>' screen:expect{grid=[[ ^hh | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]} end) @@ -4383,7 +4622,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - local markid = meths.buf_set_extmark(0, ns, 2, 0, { + local markid = api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines={ {{"Some special", "Special"}}; {{"remark about codes", "Comment"}}; @@ -4405,7 +4644,7 @@ if (h->n_buckets < new_n_buckets) { // expand | ]]} - meths.buf_set_extmark(0, ns, 2, 0, { + api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_lines={ {{"Some special", "Special"}}; {{"remark about codes", "Comment"}}; @@ -4433,7 +4672,7 @@ if (h->n_buckets < new_n_buckets) { // expand it('works with hard TABs', function() insert(example_text2) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, { + api.nvim_buf_set_extmark(0, ns, 1, 0, { virt_lines={ {{">>", "NonText"}, {"\tvery\ttabby", "Identifier"}, {"text\twith\ttabs"}}}; }) screen:expect{grid=[[ @@ -4507,8 +4746,8 @@ if (h->n_buckets < new_n_buckets) { // expand bbb ccc ddd]]) - meths.buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) - meths.buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 2, virt_lines = {{{'VIRT LINE 1', 'NonText'}}}}) + api.nvim_buf_set_extmark(0, ns, 3, 0, {end_col = 2, virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) screen:expect{grid=[[ aaa | {1:VIRT LINE 1} | @@ -4529,8 +4768,8 @@ if (h->n_buckets < new_n_buckets) { // expand ccc ddd]]) command('set number rightleft') - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true}) - meths.buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines = {{{'VIRT LINE 1', 'NonText'}}}, virt_lines_leftcol = true}) + api.nvim_buf_set_extmark(0, ns, 3, 0, {virt_lines = {{{'VIRT LINE 2', 'NonText'}}}}) screen:expect{grid=[[ aaa{9: 1 }| {1:1 ENIL TRIV}| @@ -4550,7 +4789,7 @@ if (h->n_buckets < new_n_buckets) { // expand line3 line4 line5]]) - meths.buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {virt_lines={{{"foo"}}, {{"bar"}}, {{"baz"}}}}) screen:expect{grid=[[ line1 | foo | @@ -4560,32 +4799,29 @@ if (h->n_buckets < new_n_buckets) { // expand line3 | line4 | line^5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} feed('gg') - feed('dd') + feed('yyp') screen:expect{grid=[[ - ^line2 | + line1 | foo | bar | baz | + ^line1 | + line2 | line3 | line4 | line5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]} - feed('yyp') + feed('dd') screen:expect{grid=[[ - line2 | + line1 | foo | bar | baz | @@ -4593,11 +4829,22 @@ if (h->n_buckets < new_n_buckets) { // expand line3 | line4 | line5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]} + + feed('kdd') + screen:expect([[ + ^line2 | + foo | + bar | + baz | + line3 | + line4 | + line5 | + {1:~ }|*4 + | + ]]) end) end) @@ -4612,10 +4859,11 @@ describe('decorations: signs', function() [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Grey}; [2] = {foreground = Screen.colors.Blue1, bold = true}; [3] = {background = Screen.colors.Yellow1, foreground = Screen.colors.Blue1}; + [4] = {foreground = Screen.colors.Gray100, background = Screen.colors.Red}; } - ns = meths.create_namespace 'test' - meths.set_option_value('signcolumn', 'auto:9', {}) + ns = api.nvim_create_namespace 'test' + api.nvim_set_option_value('signcolumn', 'auto:9', {}) end) local example_test3 = [[ @@ -4630,7 +4878,7 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S'}) screen:expect{grid=[[ {1: }^l1 | @@ -4639,19 +4887,16 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} - end) it('can add a single sign (with end row)', function() insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row=1}) screen:expect{grid=[[ {1: }^l1 | @@ -4660,19 +4905,16 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} - end) it('can add a single sign and text highlight', function() insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1}) + api.nvim_buf_set_extmark(0, ns, 1, 0, {sign_text='S', hl_group='Todo', end_col=1}) screen:expect{grid=[[ {1: }^l1 | S {3:l}2 | @@ -4680,20 +4922,18 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} - meths.buf_clear_namespace(0, ns, 0, -1) + api.nvim_buf_clear_namespace(0, ns, 0, -1) end) it('can add multiple signs (single extmark)', function() insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S', end_row = 2}) screen:expect{grid=[[ {1: }^l1 | @@ -4702,20 +4942,17 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} - end) it('can add multiple signs (multiple extmarks)', function() insert(example_test3) feed'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S2', end_row = 4}) screen:expect{grid=[[ {1: }^l1 | @@ -4724,9 +4961,7 @@ l5 S2l4 | S2l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4735,8 +4970,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 3, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3}) + api.nvim_buf_set_extmark(0, ns, 3, -1, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row = 3}) screen:expect{grid=[[ {1: }^l1 | S2{1: }l2 | @@ -4744,9 +4979,7 @@ l5 S1S2l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4756,8 +4989,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S1', end_row=2}) + api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S2', end_row=3}) screen:expect{grid=[[ {1: }^l1 | @@ -4766,9 +4999,7 @@ l5 S2{1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4777,8 +5008,8 @@ l5 insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=0}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2', end_row=1}) screen:expect{grid=[[ S1^l1 | @@ -4787,9 +5018,7 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4801,10 +5030,10 @@ l5 helpers.command('sign define Oldsign text=x') helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ S1S4^l1 | @@ -4813,9 +5042,7 @@ l5 {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4827,11 +5054,11 @@ l5 helpers.command('sign define Oldsign text=x') helpers.command([[exe 'sign place 42 line=2 name=Oldsign buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) - meths.buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S2'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S3', end_row = 4}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4'}) + api.nvim_buf_set_extmark(0, ns, 2, -1, {sign_text='S5'}) screen:expect{grid=[[ S1S3S4^l1 | @@ -4840,9 +5067,7 @@ l5 S3{1: }l4 | S3{1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | ]]} end) @@ -4853,21 +5078,16 @@ l5 feed 'gg' feed '2<C-e>' - meths.buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='X', end_row=3}) screen:expect{grid=[[ X {1: }^l3 | X {1: }l4 | {1: }l5 | {1: } | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 | ]]} - end) it('can add lots of signs', function() @@ -4875,29 +5095,22 @@ l5 command 'normal 10oa b c d e f g h' for i = 1, 10 do - meths.buf_set_extmark(0, ns, i, 0, { end_col = 1, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 2, { end_col = 3, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 4, { end_col = 5, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 6, { end_col = 7, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 8, { end_col = 9, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 10, { end_col = 11, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 12, { end_col = 13, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, 14, { end_col = 15, hl_group='Todo' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='W' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='X' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='Y' }) - meths.buf_set_extmark(0, ns, i, -1, { sign_text='Z' }) + api.nvim_buf_set_extmark(0, ns, i, 0, { end_col = 1, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 2, { end_col = 3, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 4, { end_col = 5, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 6, { end_col = 7, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 8, { end_col = 9, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 10, { end_col = 11, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 12, { end_col = 13, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, 14, { end_col = 15, hl_group='Todo' }) + api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='W' }) + api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='X' }) + api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Y' }) + api.nvim_buf_set_extmark(0, ns, i, -1, { sign_text='Z' }) end screen:expect{grid=[[ - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | - W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} | + W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:h} |*8 W X Y Z {3:a} {3:b} {3:c} {3:d} {3:e} {3:f} {3:g} {3:^h} | | ]]} @@ -4911,10 +5124,10 @@ l5 command('sign define Oldsign text=O3') command([[exe 'sign place 42 line=1 name=Oldsign priority=10 buffer=' . bufnr('')]]) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S4', priority=100}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S2', priority=5}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) screen:expect{grid=[[ S1S2O3S4S5^l1 | @@ -4923,7 +5136,7 @@ l5 ]]} -- Check truncation works too - meths.set_option_value('signcolumn', 'auto', {}) + api.nvim_set_option_value('signcolumn', 'auto', {}) screen:expect{grid=[[ S5^l1 | @@ -4952,10 +5165,10 @@ l5 | ]]} - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', priority=1}) screen:expect_unchanged() - meths.buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S5', priority=200}) screen:expect{grid=[[ O3O3O3O3O3O3O3O3S5^ | {2:~ }| @@ -4967,16 +5180,237 @@ l5 it('does not set signcolumn for signs without text', function() screen:try_resize(20, 3) - meths.set_option_value('signcolumn', 'auto', {}) + api.nvim_set_option_value('signcolumn', 'auto', {}) insert(example_test3) feed 'gg' - meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) screen:expect{grid=[[ ^l1 | l2 | | ]]} end) + + it('correct width when removing multiple signs from sentinel line', function() + screen:try_resize(20, 4) + insert(example_test3) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1', end_row=3}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S2'}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {invalidate = true, sign_text='S3'}) + feed('2Gdd') + + screen:expect{grid=[[ + S1l1 | + S1^l3 | + S1l4 | + | + ]]} + end) + + it('correct width with multiple overlapping signs', function() + screen:try_resize(20, 4) + insert(example_test3) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 0, -1, {sign_text='S2', end_row=2}) + api.nvim_buf_set_extmark(0, ns, 1, -1, {sign_text='S3', end_row=2}) + feed('gg') + + local s1 = [[ + S1S2^l1 | + S2S3l2 | + S2S3l3 | + | + ]] + screen:expect{grid=s1} + -- Correct width when :move'ing a line with signs + command('move2') + screen:expect{grid=[[ + S3{1: }l2 | + S1S2S3^l1 | + {1: }l3 | + | + ]]} + command('silent undo') + screen:expect{grid=s1} + command('d') + screen:expect{grid=[[ + S1S2S3^l2 | + S2S3{1: }l3 | + {1: }l4 | + | + ]]} + command('d') + screen:expect{grid=[[ + S1S2S3^l3 | + {1: }l4 | + {1: }l5 | + | + ]]} + end) + + it('correct width when adding and removing multiple signs', function() + screen:try_resize(20, 4) + insert(example_test3) + feed('gg') + command([[ + let ns = nvim_create_namespace('') + call nvim_buf_set_extmark(0, ns, 0, 0, {'sign_text':'S1', 'end_row':3}) + let s1 = nvim_buf_set_extmark(0, ns, 2, 0, {'sign_text':'S2', 'end_row':4}) + let s2 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) + let s3 = nvim_buf_set_extmark(0, ns, 6, 0, {'sign_text':'S3'}) + let s4 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) + let s5 = nvim_buf_set_extmark(0, ns, 6, 0, {'sign_text':'S3'}) + redraw! + call nvim_buf_del_extmark(0, ns, s2) + call nvim_buf_del_extmark(0, ns, s3) + call nvim_buf_del_extmark(0, ns, s4) + call nvim_buf_del_extmark(0, ns, s5) + redraw! + call nvim_buf_del_extmark(0, ns, s1) + ]]) + screen:expect{grid=[[ + S1^l1 | + S1l2 | + S1l3 | + | + ]]} + end) + + it('correct width when deleting lines', function() + screen:try_resize(20, 4) + insert(example_test3) + feed('gg') + command([[ + let ns = nvim_create_namespace('') + call nvim_buf_set_extmark(0, ns, 4, 0, {'sign_text':'S1'}) + call nvim_buf_set_extmark(0, ns, 4, 0, {'sign_text':'S2'}) + let s3 = nvim_buf_set_extmark(0, ns, 5, 0, {'sign_text':'S3'}) + call nvim_buf_del_extmark(0, ns, s3) + norm 4Gdd + ]]) + screen:expect{grid=[[ + {1: }l3 | + S1S2l5 | + {1: }^ | + | + ]]} + end) + + it('correct width when splitting lines with signs on different columns', function() + screen:try_resize(20, 4) + insert(example_test3) + feed('gg') + api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text='S1'}) + api.nvim_buf_set_extmark(0, ns, 0, 1, {sign_text='S2'}) + feed('a<cr><esc>') + screen:expect{grid=[[ + S1l | + S2^1 | + {1: }l2 | + | + ]]} + end) + + it('correct width after wiping a buffer', function() + screen:try_resize(20, 4) + insert(example_test3) + feed('gg') + local buf = api.nvim_get_current_buf() + api.nvim_buf_set_extmark(buf, ns, 0, 0, { sign_text = 'h' }) + screen:expect{grid=[[ + h ^l1 | + {1: }l2 | + {1: }l3 | + | + ]]} + api.nvim_win_set_buf(0, api.nvim_create_buf(false, true)) + api.nvim_buf_delete(buf, {unload=true, force=true}) + api.nvim_buf_set_lines(buf, 0, -1, false, {''}) + api.nvim_win_set_buf(0, buf) + screen:expect{grid=[[ + ^ | + {2:~ }|*2 + | + ]]} + end) + + it('correct width with moved marks before undo savepos', function() + screen:try_resize(20, 4) + insert(example_test3) + feed('gg') + exec_lua([[ + local ns = vim.api.nvim_create_namespace('') + vim.api.nvim_buf_set_extmark(0, ns, 0, 0, { sign_text = 'S1' }) + vim.api.nvim_buf_set_extmark(0, ns, 1, 0, { sign_text = 'S2' }) + local s3 = vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { sign_text = 'S3' }) + local s4 = vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { sign_text = 'S4' }) + vim.schedule(function() + vim.cmd('silent d3') + vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { id = s3, sign_text = 'S3' }) + vim.api.nvim_buf_set_extmark(0, ns, 2, 0, { id = s4, sign_text = 'S4' }) + vim.cmd('silent undo') + vim.api.nvim_buf_del_extmark(0, ns, s3) + end) + ]]) + + screen:expect{grid=[[ + S1^l1 | + S2l2 | + S4l3 | + | + ]]} + end) + + it('no crash with sign after many marks #27137', function() + screen:try_resize(20, 4) + insert('a') + for _ = 0, 104 do + api.nvim_buf_set_extmark(0, ns, 0, 0, {hl_group = 'Error', end_col = 1}) + end + api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1'}) + + screen:expect{grid=[[ + S1{4:^a} | + {2:~ }|*2 + | + ]]} + end) + + it('correct sort order with multiple namespaces and same id', function() + local ns2 = api.nvim_create_namespace('') + api.nvim_buf_set_extmark(0, ns, 0, 0, {sign_text = 'S1', id = 1}) + api.nvim_buf_set_extmark(0, ns2, 0, 0, {sign_text = 'S2', id = 1}) + + screen:expect{grid=[[ + S1S2^ | + {2:~ }|*8 + | + ]]} + end) + + it('correct number of signs after deleting text (#27046)', function() + command('call setline(1, ["foo"]->repeat(31))') + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 0, sign_text = 'S1'}) + api.nvim_buf_set_extmark(0, ns, 0, 0, {end_row = 0, end_col = 3, hl_group = 'Error'}) + api.nvim_buf_set_extmark(0, ns, 9, 0, {end_row = 9, sign_text = 'S2'}) + api.nvim_buf_set_extmark(0, ns, 9, 0, {end_row = 9, end_col = 3, hl_group = 'Error'}) + api.nvim_buf_set_extmark(0, ns, 19, 0, {end_row = 19, sign_text = 'S3'}) + api.nvim_buf_set_extmark(0, ns, 19, 0, {end_row = 19, end_col = 3, hl_group = 'Error'}) + api.nvim_buf_set_extmark(0, ns, 29, 0, {end_row = 29, sign_text = 'S4'}) + api.nvim_buf_set_extmark(0, ns, 29, 0, {end_row = 29, end_col = 3, hl_group = 'Error'}) + api.nvim_buf_set_extmark(0, ns, 30, 0, {end_row = 30, sign_text = 'S5'}) + api.nvim_buf_set_extmark(0, ns, 30, 0, {end_row = 30, end_col = 3, hl_group = 'Error'}) + command('0d29') + + screen:expect{grid=[[ + S1S2S3S4{4:^foo} | + S5{1: }{4:foo} | + {2:~ }|*7 + 29 fewer lines | + ]]} + + api.nvim_buf_clear_namespace(0, ns, 0, -1) + end) end) describe('decorations: virt_text', function() @@ -5002,9 +5436,9 @@ describe('decorations: virt_text', function() command 'normal 4ohello' command 'normal aVIRTUAL' - local ns = meths.create_namespace('test') + local ns = api.nvim_create_namespace('test') - meths.buf_set_extmark(0, ns, 2, 0, { + api.nvim_buf_set_extmark(0, ns, 2, 0, { virt_text = {{"hello", "String"}}, virt_text_win_col = 20, }) @@ -5015,10 +5449,7 @@ describe('decorations: virt_text', function() {1: 2 }hello {2:hello} | {1: 1 }hello | {1:5 }helloVIRTUA^L | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 | ]]} @@ -5031,10 +5462,7 @@ describe('decorations: virt_text', function() {1: 1 }hello {2:hello} | {1:4 }hell^o | {1: 1 }helloVIRTUAL | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 | ]]} end) @@ -5044,34 +5472,379 @@ describe('decorations: virt_text', function() screen:expect{grid=[[ | - hello | - hello | - hello | - hello | + hello |*4 hell^o | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 | ]]} - local ns = meths.create_namespace('ns') + local ns = api.nvim_create_namespace('ns') for row = 1, 5 do - meths.buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} }) + api.nvim_buf_set_extmark(0, ns, row, 0, { id = 1, virt_text = {{'world', 'Normal'}} }) end screen:expect{grid=[[ | - hello | - hello | - hello | - hello | + hello |*4 hell^o world | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 | ]]} end) +end) +describe('decorations: window scoped', function() + local screen, ns + before_each(function() + clear() + screen = Screen.new(20, 10) + screen:attach() + screen:set_default_attr_ids { + [1] = { foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Blue1, bold = true }, + } + + ns = api.nvim_create_namespace 'test' + + insert('12345') + end) + + local noextmarks = { + grid = [[ + 1234^5 | + {2:~ }|*8 + | + ]]} + + local function set_scoped_extmark(line, col, opts) + return api.nvim_buf_set_extmark(0, ns, line, col, vim.tbl_extend('error', { scoped = true }, opts)) + end + + it('hl_group', function() + set_scoped_extmark(0, 0, { + hl_group = 'Comment', + end_col = 3, + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + {1:123}4^5 | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + end) + + it('virt_text', function() + set_scoped_extmark(0, 0, { + virt_text = { { 'a', 'Comment' } }, + virt_text_pos = 'eol', + }) + set_scoped_extmark(0, 5, { + virt_text = { { 'b', 'Comment' } }, + virt_text_pos = 'inline', + }) + set_scoped_extmark(0, 1, { + virt_text = { { 'c', 'Comment' } }, + virt_text_pos = 'overlay', + }) + set_scoped_extmark(0, 1, { + virt_text = { { 'd', 'Comment' } }, + virt_text_pos = 'right_align', + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + 1{1:c}34^5{1:b} {1:a} {1:d}| + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + end) + + it('virt_lines', function() + set_scoped_extmark(0, 0, { + virt_lines = { { { 'a', 'Comment' } } }, + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + 1234^5 | + {1:a} | + {2:~ }|*7 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + end) + + it('redraws correctly with inline virt_text and wrapping', function() + set_scoped_extmark(0, 2, { + virt_text = {{ ('b'):rep(18), 'Comment' }}, + virt_text_pos = 'inline' + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + 12{1:bbbbbbbbbbbbbbbbbb}| + 34^5 | + {2:~ }|*7 + | + ]]} + + api.nvim_win_remove_ns(0, ns) + + screen:expect(noextmarks) + end) + + pending('sign_text', function() + -- TODO(altermo): The window signcolumn width is calculated wrongly (when `signcolumn=auto`) + -- This happens in function `win_redraw_signcols` on line containing `buf_meta_total(buf, kMTMetaSignText) > 0` + set_scoped_extmark(0, 0, { + sign_text = 'a', + sign_hl_group = 'Comment', + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + a 1234^5 | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + end) + + it('statuscolumn hl group', function() + local attrs = screen:get_default_attr_ids() + table.insert(attrs, { + foreground = Screen.colors.Brown, + }) + screen:set_default_attr_ids(attrs) + + set_scoped_extmark(0, 0, { + number_hl_group='comment', + }) + set_scoped_extmark(0, 0, { + line_hl_group='comment', + }) + + command 'set number' + + screen:expect { + grid = [[ + {3: 1 }1234^5 | + {2:~ }|*8 + | + ]]} + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + {1: 1 1234^5 }| + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect { + grid = [[ + {3: 1 }1234^5 | + {2:~ }|*8 + | + ]]} + end) + + it('spell', function() + local attrs = screen:get_default_attr_ids() + table.insert(attrs, { + special = Screen.colors.Red, undercurl = true + }) + screen:set_default_attr_ids(attrs) + api.nvim_buf_set_lines(0,0,-1,true,{'aa'}) + + set_scoped_extmark(0, 0, { + spell=true, + end_col=2, + }) + + command 'set spelloptions=noplainbuffer' + command 'set spell' + command 'syntax off' + + screen:expect { + grid = [[ + a^a | + {2:~ }|*8 + | + ]]} + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + {3:a^a} | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect { + grid = [[ + a^a | + {2:~ }|*8 + | + ]]} + end) + + it('url', function() + local url = 'https://example.com' + local attrs = screen:get_default_attr_ids() + table.insert(attrs, { + url = url, + }) + screen:set_default_attr_ids(attrs) + + set_scoped_extmark(0, 0, { + end_col=3, + url=url, + }) + + screen:expect(noextmarks) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + {3:123}4^5 | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + end) + + it('change extmarks scoped option', function() + local id = set_scoped_extmark(0, 0, { + hl_group = 'Comment', + end_col = 3, + }) + + api.nvim_win_add_ns(0, ns) + + screen:expect { + grid = [[ + {1:123}4^5 | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + + screen:expect(noextmarks) + + api.nvim_buf_set_extmark(0, ns, 0, 0, { + id = id, + hl_group = 'Comment', + end_col = 3, + scoped = false, + }) + + screen:expect { + grid = [[ + {1:123}4^5 | + {2:~ }|*8 + | + ]]} + + api.nvim_buf_set_extmark(0, ns, 0, 0, { + id = id, + hl_group = 'Comment', + end_col = 3, + scoped = true, + }) + + screen:expect(noextmarks) + end) + + it('change namespace scope', function() + set_scoped_extmark(0, 0, { + hl_group = 'Comment', + end_col = 3, + }) + + eq(true, api.nvim_win_add_ns(0, ns)) + eq({ ns }, api.nvim_win_get_ns(0)) + + screen:expect { + grid = [[ + {1:123}4^5 | + {2:~ }|*8 + | + ]]} + + command 'split' + command 'only' + eq({}, api.nvim_win_get_ns(0)) + + screen:expect(noextmarks) + + eq(true, api.nvim_win_add_ns(0, ns)) + eq({ ns }, api.nvim_win_get_ns(0)) + + screen:expect { + grid = [[ + {1:123}4^5 | + {2:~ }|*8 + | + ]]} + + eq(true, api.nvim_win_remove_ns(0, ns)) + eq({}, api.nvim_win_get_ns(0)) + + screen:expect(noextmarks) + end) end) diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua index 92b7235885..e0dfde35f2 100644 --- a/test/functional/ui/diff_spec.lua +++ b/test/functional/ui/diff_spec.lua @@ -9,7 +9,9 @@ local write_file = helpers.write_file local dedent = helpers.dedent local exec = helpers.exec local eq = helpers.eq -local meths = helpers.meths +local api = helpers.api + +before_each(clear) describe('Diff mode screen', function() local fname = 'Xtest-functional-diff-screen-1' @@ -21,7 +23,6 @@ describe('Diff mode screen', function() end setup(function() - clear() os.remove(fname) os.remove(fname_2) end) @@ -32,7 +33,6 @@ describe('Diff mode screen', function() end) before_each(function() - clear() feed(':e ' .. fname_2 .. '<cr>') feed(':vnew ' .. fname .. '<cr>') feed(':diffthis<cr>') @@ -41,21 +41,21 @@ describe('Diff mode screen', function() screen = Screen.new(40, 16) screen:attach() screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [3] = {reverse = true}, - [4] = {background = Screen.colors.LightBlue}, - [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, - [6] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {bold = true, reverse = true}, - [8] = {bold = true, background = Screen.colors.Red}, - [9] = {background = Screen.colors.LightMagenta}, + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightBlue }, + [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, + [6] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { bold = true, reverse = true }, + [8] = { bold = true, background = Screen.colors.Red }, + [9] = { background = Screen.colors.LightMagenta }, }) end) it('Add a line in beginning of file 2', function() - write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) - write_file(fname_2, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) + write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) + write_file(fname_2, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) reread() feed(':set diffopt=filler<cr>') @@ -68,12 +68,7 @@ describe('Diff mode screen', function() {1: }5 │{1: }5 | {1: }6 │{1: }6 | {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) @@ -88,23 +83,18 @@ describe('Diff mode screen', function() {1: }5 │{1: }5 | {1: }6 │{1: }6 | {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) end) it('Add a line in beginning of file 1', function() - write_file(fname, "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) - write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) + write_file(fname, '0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) + write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) reread() - feed(":set diffopt=filler<cr>") + feed(':set diffopt=filler<cr>') screen:expect([[ {1: }{4:^0 }│{1: }{2:-----------------}| {1: }1 │{1: }1 | @@ -114,17 +104,12 @@ describe('Diff mode screen', function() {1: }5 │{1: }5 | {1: }6 │{1: }6 | {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) - feed(":set diffopt+=internal<cr>") + feed(':set diffopt+=internal<cr>') screen:expect([[ {1: }{4:^0 }│{1: }{2:-----------------}| {1: }1 │{1: }1 | @@ -134,23 +119,18 @@ describe('Diff mode screen', function() {1: }5 │{1: }5 | {1: }6 │{1: }6 | {1:+ }{5:+-- 4 lines: 7···}│{1:+ }{5:+-- 4 lines: 7··}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) end) it('Add a line at the end of file 2', function() - write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) - write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false) + write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) + write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false) reread() - feed(":set diffopt=filler<cr>") + feed(':set diffopt=filler<cr>') screen:expect([[ {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}| {1: }5 │{1: }5 | @@ -160,17 +140,12 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{2:------------------}│{1: }{4:11 }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) - feed(":set diffopt+=internal<cr>") + feed(':set diffopt+=internal<cr>') screen:expect([[ {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}| {1: }5 │{1: }5 | @@ -180,12 +155,7 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{2:------------------}│{1: }{4:11 }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) @@ -205,11 +175,11 @@ describe('Diff mode screen', function() end) it('Add a line at the end of file 1', function() - write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false) - write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) + write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false) + write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) reread() - feed(":set diffopt=filler<cr>") + feed(':set diffopt=filler<cr>') screen:expect([[ {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}| {1: }5 │{1: }5 | @@ -219,17 +189,12 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{4:11 }│{1: }{2:-----------------}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) - feed(":set diffopt+=internal<cr>") + feed(':set diffopt+=internal<cr>') screen:expect([[ {1:+ }{5:^+-- 4 lines: 1···}│{1:+ }{5:+-- 4 lines: 1··}| {1: }5 │{1: }5 | @@ -239,12 +204,7 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{4:11 }│{1: }{2:-----------------}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) @@ -264,8 +224,8 @@ describe('Diff mode screen', function() end) it('Add a line in the middle of file 2, remove on at the end of file 1', function() - write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false) - write_file(fname_2, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false) + write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false) + write_file(fname_2, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false) reread() feed(':set diffopt=filler<cr>') @@ -282,8 +242,7 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{4:11 }│{1: }{2:-----------------}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*2 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) @@ -302,16 +261,15 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{4:11 }│{1: }{2:-----------------}| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*2 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) end) it('Add a line in the middle of file 1, remove on at the end of file 2', function() - write_file(fname, "1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n", false) - write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n", false) + write_file(fname, '1\n2\n3\n4\n4\n5\n6\n7\n8\n9\n10\n', false) + write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n', false) reread() feed(':set diffopt=filler<cr>') @@ -328,8 +286,7 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{2:------------------}│{1: }{4:11 }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*2 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) @@ -348,8 +305,7 @@ describe('Diff mode screen', function() {1: }9 │{1: }9 | {1: }10 │{1: }10 | {1: }{2:------------------}│{1: }{4:11 }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*2 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) @@ -567,7 +523,7 @@ int main(int argc, char **argv) it('internal', function() reread() - feed(":set diffopt=internal,filler<cr>") + feed(':set diffopt=internal,filler<cr>') screen:expect([[ {1: }^def finalize(value│{1: }def finalize(valu| {1: } │{1: } | @@ -578,11 +534,7 @@ int main(int argc, char **argv) {1: }{2:------------------}│{1: }{4: values.each do }| {1: } v.finalize │{1: } v.finalize | {1: } end │{1: } end | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*5 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=internal,filler | ]]) @@ -601,11 +553,7 @@ int main(int argc, char **argv) {1: } values.each do |│{1: } values.each do | {1: } v.finalize │{1: } v.finalize | {1: } end │{1: } end | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*5 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| | ]]) @@ -625,11 +573,7 @@ int main(int argc, char **argv) {1: } values.each do |│{1: } values.each do | {1: } v.finalize │{1: } v.finalize | {1: } end │{1: } end | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*5 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -637,26 +581,14 @@ int main(int argc, char **argv) end) it('Diff the same file', function() - write_file(fname, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) - write_file(fname_2, "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", false) + write_file(fname, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) + write_file(fname_2, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n', false) reread() feed(':set diffopt=filler<cr>') screen:expect([[ {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}| - {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:~ }| + {6:~ }│{6:~ }|*13 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) @@ -664,45 +596,21 @@ int main(int argc, char **argv) feed(':set diffopt+=internal<cr>') screen:expect([[ {1:+ }{5:^+-- 10 lines: 1···}│{1:+ }{5:+-- 10 lines: 1··}| - {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:~ }| + {6:~ }│{6:~ }|*13 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) end) it('Diff an empty file', function() - write_file(fname, "", false) - write_file(fname_2, "", false) + write_file(fname, '', false) + write_file(fname_2, '', false) reread() feed(':set diffopt=filler<cr>') screen:expect([[ {1:- }^ │{1:- } | - {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:~ }| + {6:~ }│{6:~ }|*13 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler | ]]) @@ -710,27 +618,15 @@ int main(int argc, char **argv) feed(':set diffopt+=internal<cr>') screen:expect([[ {1:- }^ │{1:- } | - {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:~ }| + {6:~ }│{6:~ }|*13 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) end) it('diffopt+=icase', function() - write_file(fname, "a\nb\ncd\n", false) - write_file(fname_2, "A\nb\ncDe\n", false) + write_file(fname, 'a\nb\ncd\n', false) + write_file(fname_2, 'A\nb\ncDe\n', false) reread() feed(':set diffopt=filler,icase<cr>') @@ -738,17 +634,7 @@ int main(int argc, char **argv) {1: }^a │{1: }A | {1: }b │{1: }b | {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler,icase | ]]) @@ -758,17 +644,7 @@ int main(int argc, char **argv) {1: }^a │{1: }A | {1: }b │{1: }b | {1: }{9:cd }│{1: }{9:cD}{8:e}{9: }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=internal | ]]) @@ -778,7 +654,8 @@ int main(int argc, char **argv) setup(function() local f1 = 'int main()\n{\n printf("Hello, World!");\n return 0;\n}\n' write_file(fname, f1, false) - local f2 = 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n' + local f2 = + 'int main()\n{\n if (0)\n {\n printf("Hello, World!");\n return 0;\n }\n}\n' write_file(fname_2, f2, false) feed(':diffupdate!<cr>') end) @@ -795,12 +672,7 @@ int main(int argc, char **argv) {1: } return 0; │{1: } return 0; | {1: }{2:------------------}│{1: }{4: } }| {1: }} │{1: }} | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler,iwhite | ]]) @@ -818,12 +690,7 @@ int main(int argc, char **argv) {1: } return 0; │{1: } return 0; | {1: }{2:------------------}│{1: }{4: } }| {1: }} │{1: }} | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=filler,iwhite,internal | ]]) @@ -842,19 +709,12 @@ int main(int argc, char **argv) feed(':set diffopt=internal,filler,iblank<cr>') screen:expect([[ {1: }^a │{1: }a | - {1: }{4: }│{1: }{2:-----------------}| - {1: }{4: }│{1: }{2:-----------------}| + {1: }{4: }│{1: }{2:-----------------}|*2 {1: }cd │{1: }cd | {1: }ef │{1: } | {1: }{8:xxx}{9: }│{1: }ef | {6:~ }│{1: }{8:yyy}{9: }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*7 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=internal,filler,iblank | ]]) @@ -871,14 +731,7 @@ int main(int argc, char **argv) {1: }cd │{1: }ef | {1: }ef │{1: }{8:yyy}{9: }| {1: }{8:xxx}{9: }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*8 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -895,14 +748,7 @@ int main(int argc, char **argv) {1: }cd │{1: }ef | {1: }ef │{1: }{8:yyy}{9: }| {1: }{8:xxx}{9: }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*8 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -919,14 +765,7 @@ int main(int argc, char **argv) {1: }cd │{1: }ef | {1: }ef │{1: }{8:yyy}{9: }| {1: }{8:xxx}{9: }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*8 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -953,12 +792,7 @@ int main(int argc, char **argv) {1: }foo │{1: }foo | {1: }{2:------------------}│{1: }{4: }| {1: }bar │{1: }bar | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -977,12 +811,7 @@ int main(int argc, char **argv) {1: }foo │{1: }foo | {1: }{2:------------------}│{1: }{4: }| {1: }bar │{1: }bar | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*6 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| : | ]]) @@ -993,7 +822,9 @@ int main(int argc, char **argv) -- This was scrolling for 'cursorbind' but 'scrollbind' is more important it('scrolling works correctly vim-patch:8.2.5155', function() screen:try_resize(40, 12) - write_file(fname, dedent([[ + write_file( + fname, + dedent([[ line 1 line 2 line 3 @@ -1007,8 +838,12 @@ int main(int argc, char **argv) // Common block // two // containing - // four lines]]), false) - write_file(fname_2, dedent([[ + // four lines]]), + false + ) + write_file( + fname_2, + dedent([[ line 1 line 2 line 3 @@ -1041,7 +876,9 @@ int main(int argc, char **argv) // Common block // two // containing - // four lines]]), false) + // four lines]]), + false + ) reread() feed('<C-W><C-W>jjjj') @@ -1116,9 +953,7 @@ int main(int argc, char **argv) {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma| {1: } MainWindow.sho│{1: } MainWindow.sh| {1: } sys.exit(app.e│{1: } sys.exit(app.| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*3 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt=internal,filler | ]]) @@ -1137,9 +972,7 @@ int main(int argc, char **argv) {1: } ui.setupUI(Mai│{1: } ui.setupUI(Ma| {1: } MainWindow.sho│{1: } MainWindow.sh| {1: } ^sys.exit(app.e│{1: } sys.exit(app.| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*3 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=linematch:20 | ]]) @@ -1163,17 +996,7 @@ ccca]] {1: }^DDD │{1: }DDD | {1: }{2:------------------}│{1: }{4:AAA }| {1: }{8:_a}{9:a }│{1: }{8:ccc}{9:a }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| | ]]) @@ -1182,17 +1005,7 @@ ccca]] {1: }^DDD │{1: }DDD | {1: }{8:_}{9:aa }│{1: }{8:A}{9:AA }| {1: }{2:------------------}│{1: }{4:ccca }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=icase | ]]) @@ -1212,53 +1025,38 @@ AAAB]] it('diffopt+=linematch:20,iwhiteall', function() reread() feed(':set diffopt=internal,filler,linematch:20<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }^BB │{1: }BB | {1: }{9: AA}{8:A}{9: }│{1: }{9: AA}{8:B}{9: }| {1: }{2:------------------}│{1: }{4:AAAB }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| | - ]]} + ]], + } feed(':set diffopt+=iwhiteall<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }^BB │{1: }BB | {1: }{2:------------------}│{1: }{4: AAB }| {1: }{9: AAA }│{1: }{9:AAA}{8:B}{9: }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {7:<onal-diff-screen-1 }{3:<l-diff-screen-1.2 }| :set diffopt+=iwhiteall | - ]]} + ]], + } end) end) it('redraws with a change to non-current buffer', function() - write_file(fname, "aaa\nbbb\nccc\n\nxx", false) - write_file(fname_2, "aaa\nbbb\nccc\n\nyy", false) + write_file(fname, 'aaa\nbbb\nccc\n\nxx', false) + write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false) reread() - local buf = meths.get_current_buf() + local buf = api.nvim_get_current_buf() command('botright new') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }aaa │{1: }aaa | {1: }bbb │{1: }bbb | {1: }ccc │{1: }ccc | @@ -1267,18 +1065,15 @@ AAAB]] {6:~ }│{6:~ }| {3:<onal-diff-screen-1 <l-diff-screen-1.2 }| ^ | - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| + {6:~ }|*6 {7:[No Name] }| :e | - ]]} + ]], + } - meths.buf_set_lines(buf, 1, 2, true, {'BBB'}) - screen:expect{grid=[[ + api.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' }) + screen:expect { + grid = [[ {1: }aaa │{1: }aaa | {1: }{8:BBB}{9: }│{1: }{8:bbb}{9: }| {1: }ccc │{1: }ccc | @@ -1287,24 +1082,21 @@ AAAB]] {6:~ }│{6:~ }| {3:<-diff-screen-1 [+] <l-diff-screen-1.2 }| ^ | - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| - {6:~ }| + {6:~ }|*6 {7:[No Name] }| :e | - ]]} + ]], + } end) - it('redraws with a change current buffer in another window', function() - write_file(fname, "aaa\nbbb\nccc\n\nxx", false) - write_file(fname_2, "aaa\nbbb\nccc\n\nyy", false) + it('redraws with a change current buffer in another window', function() + write_file(fname, 'aaa\nbbb\nccc\n\nxx', false) + write_file(fname_2, 'aaa\nbbb\nccc\n\nyy', false) reread() - local buf = meths.get_current_buf() + local buf = api.nvim_get_current_buf() command('botright split | diffoff') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }aaa │{1: }aaa | {1: }bbb │{1: }bbb | {1: }ccc │{1: }ccc | @@ -1317,14 +1109,15 @@ AAAB]] ccc | | xx | - {6:~ }| - {6:~ }| + {6:~ }|*2 {7:Xtest-functional-diff-screen-1 }| :e | - ]]} + ]], + } - meths.buf_set_lines(buf, 1, 2, true, {'BBB'}) - screen:expect{grid=[[ + api.nvim_buf_set_lines(buf, 1, 2, true, { 'BBB' }) + screen:expect { + grid = [[ {1: }aaa │{1: }aaa | {1: }{8:BBB}{9: }│{1: }{8:bbb}{9: }| {1: }ccc │{1: }ccc | @@ -1337,38 +1130,41 @@ AAAB]] ccc | | xx | - {6:~ }| - {6:~ }| + {6:~ }|*2 {7:Xtest-functional-diff-screen-1 [+] }| :e | - ]]} + ]], + } end) end) it('win_update redraws lines properly', function() local screen - clear() screen = Screen.new(50, 10) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {background = Screen.colors.Red, foreground = Screen.colors.Grey100, special = Screen.colors.Yellow}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {special = Screen.colors.Yellow}, - [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4}, - [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100}, - [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100}, - [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100}, - [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')}, - [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452')}, - [12] = {bold = true, reverse = true}, - [13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [14] = {reverse = true}, - [15] = {background = Screen.colors.LightBlue}, - [16] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [17] = {bold = true, background = Screen.colors.Red}, - [18] = {background = Screen.colors.LightMagenta}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { + background = Screen.colors.Red, + foreground = Screen.colors.Grey100, + special = Screen.colors.Yellow, + }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { special = Screen.colors.Yellow }, + [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 }, + [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 }, + [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 }, + [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 }, + [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') }, + [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') }, + [12] = { bold = true, reverse = true }, + [13] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [14] = { reverse = true }, + [15] = { background = Screen.colors.LightBlue }, + [16] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 }, + [17] = { bold = true, background = Screen.colors.Red }, + [18] = { background = Screen.colors.LightMagenta }, }) insert([[ @@ -1378,18 +1174,18 @@ it('win_update redraws lines properly', function() 2 1a ]]) - command("vnew left") + command('vnew left') insert([[ 2 2a 2b ]]) - command("windo diffthis") - command("windo 1") - screen:expect{grid=[[ + command('windo diffthis') + command('windo 1') + screen:expect { + grid = [[ {13: }{16:-----------------------}│{13: }{15:^1 }| - {13: }{16:-----------------------}│{13: }{15: }| - {13: }{16:-----------------------}│{13: }{15: }| + {13: }{16:-----------------------}│{13: }{15: }|*2 {13: }2 │{13: }2 | {13: }{17:2}{18:a }│{13: }{17:1}{18:a }| {13: }{15:2b }│{13: }{16:----------------------}| @@ -1397,13 +1193,15 @@ it('win_update redraws lines properly', function() {1:~ }│{1:~ }| {14:left [+] }{12:[No Name] [+] }| | - ]]} + ]], + } feed('<C-e>') feed('<C-e>') feed('<C-y>') feed('<C-y>') feed('<C-y>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {13: }{16:-----------------------}│{13: }{15:1 }| {13: }{16:-----------------------}│{13: }{15: }| {13: }{16:-----------------------}│{13: }{15:^ }| @@ -1414,26 +1212,26 @@ it('win_update redraws lines properly', function() {1:~ }│{1:~ }| {14:left [+] }{12:[No Name] [+] }| | - ]]} + ]], + } end) -- oldtest: Test_diff_rnu() it('diff updates line numbers below filler lines', function() - clear() local screen = Screen.new(40, 14) screen:attach() screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [3] = {reverse = true}, - [4] = {background = Screen.colors.LightBlue}, - [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, - [6] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {bold = true, reverse = true}, - [8] = {bold = true, background = Screen.colors.Red}, - [9] = {background = Screen.colors.LightMagenta}, - [10] = {bold = true, foreground = Screen.colors.Brown}, - [11] = {foreground = Screen.colors.Brown}, + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightBlue }, + [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, + [6] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { bold = true, reverse = true }, + [8] = { bold = true, background = Screen.colors.Red }, + [9] = { background = Screen.colors.LightMagenta }, + [10] = { bold = true, foreground = Screen.colors.Brown }, + [11] = { foreground = Screen.colors.Brown }, }) exec([[ call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b']) @@ -1447,8 +1245,7 @@ it('diff updates line numbers below filler lines', function() {1: }a │{11: 1 }a | {1: }a │{11: 2 }a | {1: }{8:x}{9: }│{11: 3 }{8:y}{9: }| - {1: }{4:x }│{11: }{2:----------------}| - {1: }{4:x }│{11: }{2:----------------}| + {1: }{4:x }│{11: }{2:----------------}|*2 {1: }b │{11: 4 }b | {1: }b │{11: 5 }b | {1: }b │{11: 6 }b | @@ -1464,8 +1261,7 @@ it('diff updates line numbers below filler lines', function() {1: }a │{10:2 }^a | {1: }a │{11: 1 }a | {1: }{8:x}{9: }│{11: 2 }{8:y}{9: }| - {1: }{4:x }│{11: }{2:----------------}| - {1: }{4:x }│{11: }{2:----------------}| + {1: }{4:x }│{11: }{2:----------------}|*2 {1: }b │{11: 3 }b | {1: }b │{11: 4 }b | {1: }b │{11: 5 }b | @@ -1481,8 +1277,7 @@ it('diff updates line numbers below filler lines', function() {1: }a │{11: 1 }a | {1: }a │{10:3 }^a | {1: }{8:x}{9: }│{11: 1 }{8:y}{9: }| - {1: }{4:x }│{11: }{2:----------------}| - {1: }{4:x }│{11: }{2:----------------}| + {1: }{4:x }│{11: }{2:----------------}|*2 {1: }b │{11: 2 }b | {1: }b │{11: 3 }b | {1: }b │{11: 4 }b | @@ -1496,18 +1291,17 @@ end) -- oldtest: Test_diff_with_scroll_and_change() it('Align the filler lines when changing text in diff mode', function() - clear() local screen = Screen.new(40, 20) screen:attach() screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray}; - [2] = {background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true}; - [3] = {reverse = true}; - [4] = {background = Screen.colors.LightBlue}; - [5] = {background = Screen.colors.LightMagenta}; - [6] = {background = Screen.colors.Red, bold = true}; - [7] = {foreground = Screen.colors.Blue1, bold = true}; - [8] = {reverse = true, bold = true}; + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray }, + [2] = { background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1, bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightBlue }, + [5] = { background = Screen.colors.LightMagenta }, + [6] = { background = Screen.colors.Red, bold = true }, + [7] = { foreground = Screen.colors.Blue1, bold = true }, + [8] = { reverse = true, bold = true }, }) exec([[ call setline(1, range(1, 15)) @@ -1517,7 +1311,8 @@ it('Align the filler lines when changing text in diff mode', function() wincmd h exe "normal Gl5\<C-E>" ]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }{2:------------------}│{1: }{4:6 }| {1: }{2:------------------}│{1: }{4:7 }| {1: }{2:------------------}│{1: }{4:8 }| @@ -1528,19 +1323,14 @@ it('Align the filler lines when changing text in diff mode', function() {1: }13 │{1: }13 | {1: }14 │{1: }14 | {1:- }1^5 │{1:- }15 | - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| + {7:~ }│{7:~ }|*8 {8:[No Name] [+] }{3:[No Name] [+] }| | - ]]} + ]], + } feed('ax<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }{2:------------------}│{1: }{4:6 }| {1: }{2:------------------}│{1: }{4:7 }| {1: }{2:------------------}│{1: }{4:8 }| @@ -1551,19 +1341,14 @@ it('Align the filler lines when changing text in diff mode', function() {1: }13 │{1: }13 | {1: }14 │{1: }14 | {1: }{5:15}{6:^x}{5: }│{1: }{5:15 }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| + {7:~ }│{7:~ }|*8 {8:[No Name] [+] }{3:[No Name] [+] }| | - ]]} + ]], + } feed('<C-W>lay<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }{2:-----------------}│{1: }{4:6 }| {1: }{2:-----------------}│{1: }{4:7 }| {1: }{2:-----------------}│{1: }{4:8 }| @@ -1574,52 +1359,41 @@ it('Align the filler lines when changing text in diff mode', function() {1: }13 │{1: }13 | {1: }14 │{1: }14 | {1: }{5:15}{6:x}{5: }│{1: }{5:15}{6:^y}{5: }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| + {7:~ }│{7:~ }|*8 {3:[No Name] [+] }{8:[No Name] [+] }| | - ]]} + ]], + } end) it("diff mode doesn't restore invalid 'foldcolumn' value #21647", function() - clear() local screen = Screen.new(60, 6) screen:set_default_attr_ids({ - [0] = {foreground = Screen.colors.Blue, bold = true}; + [0] = { foreground = Screen.colors.Blue, bold = true }, }) screen:attach() - eq('0', meths.get_option_value('foldcolumn', {})) + eq('0', api.nvim_get_option_value('foldcolumn', {})) command('diffsplit | bd') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) - eq('0', meths.get_option_value('foldcolumn', {})) + eq('0', api.nvim_get_option_value('foldcolumn', {})) end) -- oldtest: Test_diff_binary() it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', function() - clear() local screen = Screen.new(40, 20) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray}; - [2] = {reverse = true}; - [3] = {background = Screen.colors.LightBlue}; - [4] = {background = Screen.colors.LightMagenta}; - [5] = {background = Screen.colors.Red, bold = true}; - [6] = {foreground = Screen.colors.Blue, bold = true}; - [7] = {background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true}; - [8] = {reverse = true, bold = true}; + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Gray }, + [2] = { reverse = true }, + [3] = { background = Screen.colors.LightBlue }, + [4] = { background = Screen.colors.LightMagenta }, + [5] = { background = Screen.colors.Red, bold = true }, + [6] = { foreground = Screen.colors.Blue, bold = true }, + [7] = { background = Screen.colors.Red, foreground = Screen.colors.Blue, bold = true }, + [8] = { reverse = true, bold = true }, }) screen:attach() exec([[ @@ -1641,17 +1415,7 @@ it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', fun {1: }{5:E}{4: }│{1: }{5:e}{4: }| {1: }f │{1: }f | {1: }g │{1: }g | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {8:[No Name] [+] }{2:[No Name] [+] }| | ]]) @@ -1667,17 +1431,7 @@ it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', fun {1: }E │{1: }e | {1: }f │{1: }f | {1: }g │{1: }g | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {8:[No Name] [+] }{2:[No Name] [+] }| | ]]) @@ -1693,17 +1447,7 @@ it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', fun {1: }{5:E}{4: }│{1: }{5:e}{4: }| {1: }f │{1: }f | {1: }g │{1: }g | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {8:[No Name] [+] }{2:[No Name] [+] }| | ]]) @@ -1719,18 +1463,36 @@ it('diff mode works properly if file contains NUL bytes vim-patch:8.2.3925', fun {1: }E │{1: }e | {1: }f │{1: }f | {1: }g │{1: }g | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*11 {8:[No Name] [+] }{2:[No Name] [+] }| | ]]) end) + +-- oldtest: Test_diff_breakindent_after_filler() +it("diff mode draws 'breakindent' correctly after filler lines", function() + local screen = Screen.new(45, 8) + screen:attach() + screen:set_default_attr_ids({ + [1] = { background = Screen.colors.Grey, foreground = Screen.colors.DarkBlue }, + [2] = { background = Screen.colors.LightBlue }, + [3] = { background = Screen.colors.LightCyan, bold = true, foreground = Screen.colors.Blue }, + [4] = { foreground = Screen.colors.Blue, bold = true }, + }) + exec([[ + set laststatus=0 diffopt+=followwrap breakindent breakindentopt=min:0 + call setline(1, ['a', ' ' .. repeat('c', 50)]) + vnew + call setline(1, ['a', 'b', ' ' .. repeat('c', 50)]) + windo diffthis + norm! G$ + ]]) + screen:expect([[ + {1: }a │{1: }a | + {1: }{2:b }│{1: }{3:--------------------}| + {1: } cccccccccccccccccc│{1: } cccccccccccccccccc|*2 + {1: } cccccccccccccc │{1: } ccccccccccccc^c | + {4:~ }│{4:~ }|*2 + | + ]]) +end) diff --git a/test/functional/ui/embed_spec.lua b/test/functional/ui/embed_spec.lua index 9729f65355..0445476780 100644 --- a/test/functional/ui/embed_spec.lua +++ b/test/functional/ui/embed_spec.lua @@ -1,56 +1,53 @@ -local uv = require'luv' +local uv = vim.uv local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local api = helpers.api local feed = helpers.feed local eq = helpers.eq local neq = helpers.neq local clear = helpers.clear local ok = helpers.ok -local funcs = helpers.funcs +local fn = helpers.fn local nvim_prog = helpers.nvim_prog local retry = helpers.retry +local write_file = helpers.write_file local function test_embed(ext_linegrid) local screen local function startup(...) - clear{args_rm={'--headless'}, args={...}} + clear { args_rm = { '--headless' }, args = { ... } } -- attach immediately after startup, for early UI screen = Screen.new(60, 8) - screen:attach{ext_linegrid=ext_linegrid} + screen:attach { ext_linegrid = ext_linegrid } screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [2] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [3] = {bold = true, foreground = Screen.colors.Blue1}, - [4] = {bold = true, foreground = Screen.colors.Green}, - [5] = {bold = true, reverse = true}, + [1] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [2] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [3] = { bold = true, foreground = Screen.colors.Blue1 }, + [4] = { bold = true, foreground = Screen.colors.Green }, + [5] = { bold = true, reverse = true }, + [6] = { foreground = Screen.colors.NvimLightGrey3, background = Screen.colors.NvimDarkGrey3 }, + [7] = { foreground = Screen.colors.NvimDarkRed }, + [8] = { foreground = Screen.colors.NvimDarkCyan }, }) end it('can display errors', function() startup('--cmd', 'echoerr invalid+') screen:expect([[ - | - | - | - | - | - Error detected while processing pre-vimrc command line: | - E121: Undefined variable: invalid | - Press ENTER or type command to continue^ | + |*4 + {6: }| + {7:Error detected while processing pre-vimrc command line:} | + {7:E121: Undefined variable: invalid} | + {8:Press ENTER or type command to continue}^ | ]]) feed('<cr>') screen:expect([[ ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*6 | ]]) end) @@ -61,36 +58,39 @@ local function test_embed(ext_linegrid) end startup('--cmd', 'echoerr "foo"', '--cmd', 'color default', '--cmd', 'echoerr "bar"') screen:expect([[ - | - | - | - {5: }| - Error detected while processing pre-vimrc command line: | - foo | - {1:bar} | - {4:Press ENTER or type command to continue}^ | + |*3 + {6: }| + {7:Error detected while processing pre-vimrc command line:} | + {7:foo} | + {7:bar} | + {8:Press ENTER or type command to continue}^ | ]]) end) it("doesn't erase output when setting Normal colors", function() startup('--cmd', 'echoerr "foo"', '--cmd', 'hi Normal guibg=Green', '--cmd', 'echoerr "bar"') - screen:expect{grid=[[ - | - | - | - | - Error detected while processing pre-vimrc command line: | - foo | - bar | - Press ENTER or type command to continue^ | - ]], condition=function() - eq(Screen.colors.Green, screen.default_colors.rgb_bg) - end} + screen:expect { + grid = [[ + |*3 + {6: }| + {7:Error detected while processing pre-vimrc command line:} | + {7:foo} | + {7:bar} | + {8:Press ENTER or type command to continue}^ | + ]], + condition = function() + eq(Screen.colors.Green, screen.default_colors.rgb_bg) + end, + } end) end -describe('--embed UI on startup (ext_linegrid=true)', function() test_embed(true) end) -describe('--embed UI on startup (ext_linegrid=false)', function() test_embed(false) end) +describe('--embed UI on startup (ext_linegrid=true)', function() + test_embed(true) +end) +describe('--embed UI on startup (ext_linegrid=false)', function() + test_embed(false) +end) describe('--embed UI', function() it('can pass stdin', function() @@ -99,43 +99,186 @@ describe('--embed UI', function() local writer = assert(uv.new_pipe(false)) writer:open(pipe.write) - clear {args_rm={'--headless'}, io_extra=pipe.read} + clear { args_rm = { '--headless' }, io_extra = pipe.read } -- attach immediately after startup, for early UI local screen = Screen.new(40, 8) - screen.rpc_async = true -- Avoid hanging. #24888 - screen:attach {stdin_fd=3} + screen.rpc_async = true -- Avoid hanging. #24888 + screen:attach { stdin_fd = 3 } screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {bold = true}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true }, } - writer:write "hello nvim\nfrom external input\n" - writer:shutdown(function() writer:close() end) + writer:write 'hello nvim\nfrom external input\n' + writer:shutdown(function() + writer:close() + end) - screen:expect{grid=[[ + screen:expect [[ ^hello nvim | from external input | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | - ]]} + ]] -- stdin (rpc input) still works feed 'o' - screen:expect{grid=[[ + screen:expect [[ hello nvim | ^ | from external input | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {2:-- INSERT --} | - ]]} + ]] + end) + + it('can pass stdin to -q - #17523', function() + write_file( + 'Xbadfile.c', + [[ + /* some file with an error */ + main() { + functionCall(arg; arg, arg); + return 666 + } + ]] + ) + finally(function() + os.remove('Xbadfile.c') + end) + + local pipe = assert(uv.pipe()) + + local writer = assert(uv.new_pipe(false)) + writer:open(pipe.write) + + clear { args_rm = { '--headless' }, args = { '-q', '-' }, io_extra = pipe.read } + + -- attach immediately after startup, for early UI + local screen = Screen.new(60, 8) + screen.rpc_async = true -- Avoid hanging. #24888 + screen:attach { stdin_fd = 3 } + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true }, + } + + writer:write [[Xbadfile.c:4:12: error: expected ';' before '}' token]] + writer:shutdown(function() + writer:close() + end) + + screen:expect [[ + /* some file with an error */ | + main() { | + functionCall(arg; arg, arg); | + return 66^6 | + } | + {1:~ }|*2 + (1 of 1): error: expected ';' before '}' token | + ]] + + -- stdin (rpc input) still works + feed 'A' + screen:expect [[ + /* some file with an error */ | + main() { | + functionCall(arg; arg, arg); | + return 666^ | + } | + {1:~ }|*2 + {2:-- INSERT --} | + ]] + + eq('-', api.nvim_get_option_value('errorfile', {})) + end) + + it('only sets background colors once even if overridden', function() + local screen, current, seen + local function handle_default_colors_set(_, _, rgb_bg, _, _, _) + seen[rgb_bg] = true + current = rgb_bg + end + local function startup(...) + seen = {} + current = nil + clear { args_rm = { '--headless' }, args = { ... } } + + -- attach immediately after startup, for early UI + screen = Screen.new(40, 8) + screen._handle_default_colors_set = handle_default_colors_set + screen:attach() + end + + startup() + screen:expect { + condition = function() + eq(16777215, current) + end, + } + eq({ [16777215] = true }, seen) + + -- NB: by accident how functional/helpers.lua currently handles the default color scheme, the + -- above is sufficient to test the behavior. But in case that workaround is removed, we need + -- a test with an explicit override like below, so do it to remain safe. + startup('--cmd', 'hi NORMAL guibg=#FF00FF') + screen:expect { + condition = function() + eq(16711935, current) + end, + } + eq({ [16711935] = true }, seen) -- we only saw the last one, despite 16777215 was set internally earlier + end) + + it('updates cwd of attached UI #21771', function() + clear { args_rm = { '--headless' } } + + local screen = Screen.new(40, 8) + screen:attach() + + screen:expect { + condition = function() + eq(helpers.paths.test_source_path, screen.pwd) + end, + } + + -- Change global cwd + helpers.command(string.format('cd %s/src/nvim', helpers.paths.test_source_path)) + + screen:expect { + condition = function() + eq(string.format('%s/src/nvim', helpers.paths.test_source_path), screen.pwd) + end, + } + + -- Split the window and change the cwd in the split + helpers.command('new') + helpers.command(string.format('lcd %s/test', helpers.paths.test_source_path)) + + screen:expect { + condition = function() + eq(string.format('%s/test', helpers.paths.test_source_path), screen.pwd) + end, + } + + -- Move to the original window + helpers.command('wincmd p') + + screen:expect { + condition = function() + eq(string.format('%s/src/nvim', helpers.paths.test_source_path), screen.pwd) + end, + } + + -- Change global cwd again + helpers.command(string.format('cd %s', helpers.paths.test_source_path)) + + screen:expect { + condition = function() + eq(helpers.paths.test_source_path, screen.pwd) + end, + } end) end) @@ -144,8 +287,18 @@ describe('--embed --listen UI', function() helpers.skip(helpers.is_os('win')) clear() local child_server = assert(helpers.new_pipename()) - funcs.jobstart({nvim_prog, '--embed', '--listen', child_server, '--clean'}) - retry(nil, nil, function() neq(nil, uv.fs_stat(child_server)) end) + fn.jobstart({ + nvim_prog, + '--embed', + '--listen', + child_server, + '--clean', + '--cmd', + 'colorscheme vim', + }) + retry(nil, nil, function() + neq(nil, uv.fs_stat(child_server)) + end) local child_session = helpers.connect(child_server) @@ -154,11 +307,15 @@ describe('--embed --listen UI', function() eq(2, #api_info) ok(api_info[1] > 2, 'channel_id > 2', api_info[1]) - child_session:request('nvim_exec2', [[ + child_session:request( + 'nvim_exec2', + [[ let g:evs = [] autocmd UIEnter * call add(g:evs, $"UIEnter:{v:event.chan}") autocmd VimEnter * call add(g:evs, "VimEnter") - ]], {}) + ]], + {} + ) -- VimEnter and UIEnter shouldn't be triggered until after attach local var_ok, var = child_session:request('nvim_get_var', 'evs') @@ -167,21 +324,22 @@ describe('--embed --listen UI', function() local child_screen = Screen.new(40, 6) child_screen:attach(nil, child_session) - child_screen:expect{grid=[[ + child_screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:[No Name] 0,0-1 All}| | - ]], attr_ids={ - [1] = {foreground = Screen.colors.Blue, bold = true}; - [2] = {reverse = true, bold = true}; - }} + ]], + attr_ids = { + [1] = { foreground = Screen.colors.Blue, bold = true }, + [2] = { reverse = true, bold = true }, + }, + } -- VimEnter and UIEnter should now be triggered var_ok, var = child_session:request('nvim_get_var', 'evs') ok(var_ok) - eq({'VimEnter', ('UIEnter:%d'):format(api_info[1])}, var) + eq({ 'VimEnter', ('UIEnter:%d'):format(api_info[1]) }, var) end) end) diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index 2902b4a4a5..cdb3b79963 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1,6 +1,5 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local global_helpers = require('test.helpers') local os = require('os') local clear, feed = helpers.clear, helpers.feed local assert_alive = helpers.assert_alive @@ -12,14 +11,15 @@ local expect = helpers.expect local exec = helpers.exec local exec_lua = helpers.exec_lua local insert = helpers.insert -local meths = helpers.meths -local curbufmeths = helpers.curbufmeths -local funcs = helpers.funcs +local api = helpers.api +local fn = helpers.fn local run = helpers.run local pcall_err = helpers.pcall_err -local tbl_contains = global_helpers.tbl_contains -local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab -local NIL = helpers.NIL +local tbl_contains = vim.tbl_contains +local curbuf = helpers.api.nvim_get_current_buf +local curwin = helpers.api.nvim_get_current_win +local curtab = helpers.api.nvim_get_current_tabpage +local NIL = vim.NIL describe('float window', function() before_each(function() @@ -31,36 +31,36 @@ describe('float window', function() -- Create three windows and test that ":wincmd <direction>" changes to the -- first window, if the previous window is invalid. command('split') - meths.open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0}) - eq(1002, funcs.win_getid()) - eq('editor', meths.win_get_config(1002).relative) + api.nvim_open_win(0, true, {width=10, height=10, relative='editor', row=0, col=0}) + eq(1002, fn.win_getid()) + eq('editor', api.nvim_win_get_config(1002).relative) command([[ call nvim_win_close(1001, v:false) wincmd j ]]) - eq(1000, funcs.win_getid()) + eq(1000, fn.win_getid()) end) it('win_execute() should work' , function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'}) - local win = meths.open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10}) - local line = funcs.win_execute(win, 'echo getline(1)') + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin', 'abc', 'def'}) + local win = api.nvim_open_win(buf, false, {relative='win', width=16, height=1, row=0, col=10}) + local line = fn.win_execute(win, 'echo getline(1)') eq('\nthe floatwin', line) - eq('\n1', funcs.win_execute(win, 'echo line(".",'..win.id..')')) - eq('\n3', funcs.win_execute(win, 'echo line("$",'..win.id..')')) - eq('\n0', funcs.win_execute(win, 'echo line("$", 123456)')) - funcs.win_execute(win, 'bwipe!') + eq('\n1', fn.win_execute(win, 'echo line(".",'..win..')')) + eq('\n3', fn.win_execute(win, 'echo line("$",'..win..')')) + eq('\n0', fn.win_execute(win, 'echo line("$", 123456)')) + fn.win_execute(win, 'bwipe!') end) it("win_execute() call commands that are not allowed when 'hidden' is not set" , function() command('set nohidden') - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'the floatwin'}) - local win = meths.open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10}) - eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(funcs.win_execute, win, 'close')) - eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(funcs.win_execute, win, 'bdelete')) - funcs.win_execute(win, 'bwipe!') + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'the floatwin'}) + local win = api.nvim_open_win(buf, true, {relative='win', width=16, height=1, row=0, col=10}) + eq('Vim(close):E37: No write since last change (add ! to override)', pcall_err(fn.win_execute, win, 'close')) + eq('Vim(bdelete):E89: No write since last change for buffer 2 (add ! to override)', pcall_err(fn.win_execute, win, 'bdelete')) + fn.win_execute(win, 'bwipe!') end) it('closed immediately by autocmd #11383', function() @@ -104,14 +104,20 @@ describe('float window', function() end) it('open with WinNew autocmd', function() - local res = exec_lua([[ - local triggerd = false + local new_triggered_before_enter, new_curwin, win = unpack(exec_lua([[ + local enter_triggered = false + local new_triggered_before_enter = false + local new_curwin local buf = vim.api.nvim_create_buf(true, true) + vim.api.nvim_create_autocmd('WinEnter', { + callback = function() + enter_triggered = true + end + }) vim.api.nvim_create_autocmd('WinNew', { - callback = function(opt) - if opt.buf == buf then - triggerd = true - end + callback = function() + new_triggered_before_enter = not enter_triggered + new_curwin = vim.api.nvim_get_current_win() end }) local opts = { @@ -120,10 +126,11 @@ describe('float window', function() width = 1, height = 1, noautocmd = false, } - vim.api.nvim_open_win(buf, true, opts) - return triggerd - ]]) - eq(true, res) + local win = vim.api.nvim_open_win(buf, true, opts) + return {new_triggered_before_enter, new_curwin, win} + ]])) + eq(true, new_triggered_before_enter) + eq(win, new_curwin) end) it('opened with correct height', function() @@ -193,7 +200,7 @@ describe('float window', function() end) it('opened with correct position relative to the mouse', function() - meths.input_mouse('left', 'press', '', 0, 10, 10) + api.nvim_input_mouse('left', 'press', '', 0, 10, 10) local pos = exec_lua([[ local bufnr = vim.api.nvim_create_buf(false, true) @@ -480,67 +487,67 @@ describe('float window', function() it('no crash with bufpos and non-existent window', function() command('new') - local closed_win = meths.get_current_win().id + local closed_win = api.nvim_get_current_win() command('close') - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}}) + local buf = api.nvim_create_buf(false,false) + api.nvim_open_win(buf, true, {relative='win', win=closed_win, width=1, height=1, bufpos={0,0}}) assert_alive() end) it("no segfault when setting minimal style after clearing local 'fillchars' #19510", function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('fillchars', NIL, {win=float_win.id}) + local float_win = api.nvim_open_win(0, true, float_opts) + api.nvim_set_option_value('fillchars', NIL, {win=float_win}) float_opts.style = 'minimal' - meths.win_set_config(float_win, float_opts) + api.nvim_win_set_config(float_win, float_opts) assert_alive() end) it("should re-apply 'style' when present", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('number', true, { win = float_win }) + local float_win = api.nvim_open_win(0, true, float_opts) + api.nvim_set_option_value('number', true, { win = float_win }) float_opts.row = 2 - meths.win_set_config(float_win, float_opts) - eq(false, meths.get_option_value('number', { win = float_win })) + api.nvim_win_set_config(float_win, float_opts) + eq(false, api.nvim_get_option_value('number', { win = float_win })) end) it("should not re-apply 'style' when missing", function() local float_opts = {style = 'minimal', relative = 'editor', row = 1, col = 1, width = 1, height = 1} - local float_win = meths.open_win(0, true, float_opts) - meths.set_option_value('number', true, { win = float_win }) + local float_win = api.nvim_open_win(0, true, float_opts) + api.nvim_set_option_value('number', true, { win = float_win }) float_opts.row = 2 float_opts.style = nil - meths.win_set_config(float_win, float_opts) - eq(true, meths.get_option_value('number', { win = float_win })) + api.nvim_win_set_config(float_win, float_opts) + eq(true, api.nvim_get_option_value('number', { win = float_win })) end) it("'scroll' is computed correctly when opening float with splitkeep=screen #20684", function() - meths.set_option_value('splitkeep', 'screen', {}) + api.nvim_set_option_value('splitkeep', 'screen', {}) local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} - local float_win = meths.open_win(0, true, float_opts) - eq(5, meths.get_option_value('scroll', {win=float_win.id})) + local float_win = api.nvim_open_win(0, true, float_opts) + eq(5, api.nvim_get_option_value('scroll', {win=float_win})) end) it(':unhide works when there are floating windows', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} local w0 = curwin() - meths.open_win(0, false, float_opts) - meths.open_win(0, false, float_opts) - eq(3, #meths.list_wins()) + api.nvim_open_win(0, false, float_opts) + api.nvim_open_win(0, false, float_opts) + eq(3, #api.nvim_list_wins()) command('unhide') - eq({ w0 }, meths.list_wins()) + eq({ w0 }, api.nvim_list_wins()) end) it(':all works when there are floating windows', function() command('args Xa.txt') local float_opts = {relative = 'editor', row = 1, col = 1, width = 5, height = 5} local w0 = curwin() - meths.open_win(0, false, float_opts) - meths.open_win(0, false, float_opts) - eq(3, #meths.list_wins()) + api.nvim_open_win(0, false, float_opts) + api.nvim_open_win(0, false, float_opts) + eq(3, #api.nvim_list_wins()) command('all') - eq({ w0 }, meths.list_wins()) + eq({ w0 }, api.nvim_list_wins()) end) describe('with only one tabpage,', function() @@ -548,42 +555,42 @@ describe('float window', function() local old_buf, old_win before_each(function() insert('foo') - old_buf = curbuf().id - old_win = curwin().id + old_buf = curbuf() + old_win = curwin() end) describe('closing the last non-floating window gives E444', function() before_each(function() - meths.open_win(old_buf, true, float_opts) + api.nvim_open_win(old_buf, true, float_opts) end) it('if called from non-floating window', function() - meths.set_current_win(old_win) + api.nvim_set_current_win(old_win) eq('Vim:E444: Cannot close last window', - pcall_err(meths.win_close, old_win, false)) + pcall_err(api.nvim_win_close, old_win, false)) end) it('if called from floating window', function() eq('Vim:E444: Cannot close last window', - pcall_err(meths.win_close, old_win, false)) + pcall_err(api.nvim_win_close, old_win, false)) end) end) describe("deleting the last non-floating window's buffer", function() describe('leaves one window with an empty buffer when there is only one buffer', function() local same_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) end) after_each(function() - eq(old_win, curwin().id) + eq(old_win, curwin()) expect('') - eq(1, #meths.list_wins()) + eq(1, #api.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) + api.nvim_buf_delete(old_buf, {force = true}) end) it('if called from floating window', function() - meths.set_current_win(same_buf_float) + api.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + api.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) end) @@ -591,67 +598,67 @@ describe('float window', function() describe('closes other windows with that buffer when there are other buffers', function() local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) + other_buf = api.nvim_create_buf(true, false) + other_buf_float = api.nvim_open_win(other_buf, true, float_opts) insert('bar') - meths.set_current_win(old_win) + api.nvim_set_current_win(old_win) end) after_each(function() - eq(other_buf, curbuf().id) + eq(other_buf, curbuf()) expect('bar') - eq(2, #meths.list_wins()) + eq(2, #api.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, curwin().id) + api.nvim_buf_delete(old_buf, {force = true}) + eq(old_win, curwin()) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + api.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + api.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) - eq(old_win, curwin().id) + eq(old_win, curwin()) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_float) - meths.buf_delete(old_buf, {force = true}) + api.nvim_set_current_win(other_buf_float) + api.nvim_buf_delete(old_buf, {force = true}) end) end) describe('creates an empty buffer when there is only one listed buffer', function() local same_buf_float, unlisted_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - local unlisted_buf = meths.create_buf(true, false).id - unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) + local unlisted_buf = api.nvim_create_buf(true, false) + unlisted_buf_float = api.nvim_open_win(unlisted_buf, true, float_opts) insert('unlisted') command('set nobuflisted') - meths.set_current_win(old_win) + api.nvim_set_current_win(old_win) end) after_each(function() expect('') - eq(2, #meths.list_wins()) + eq(2, #api.nvim_list_wins()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, curwin().id) + api.nvim_buf_delete(old_buf, {force = true}) + eq(old_win, curwin()) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + api.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + api.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) - eq(old_win, curwin().id) + eq(old_win, curwin()) end) -- TODO: this case is too hard to deal with pending('if called from floating window with an unlisted buffer', function() - meths.set_current_win(unlisted_buf_float) - meths.buf_delete(old_buf, {force = true}) + api.nvim_set_current_win(unlisted_buf_float) + api.nvim_buf_delete(old_buf, {force = true}) end) end) end) @@ -662,21 +669,21 @@ describe('float window', function() command('botright vnew') insert('unlisted') command('set nobuflisted') - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + api.nvim_set_current_win(old_win) + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) end) after_each(function() expect('') - eq(2, #meths.list_wins()) + eq(2, #api.nvim_list_wins()) end) it('if called from non-floating window with the deleted buffer', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, curwin().id) + api.nvim_buf_delete(old_buf, {force = true}) + eq(old_win, curwin()) end) it('if called from floating window with the deleted buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = true}) - eq(same_buf_float, curwin().id) + api.nvim_set_current_win(same_buf_float) + api.nvim_buf_delete(old_buf, {force = true}) + eq(same_buf_float, curwin()) end) end) end) @@ -688,63 +695,63 @@ describe('float window', function() before_each(function() insert('unlisted') command('set nobuflisted') - unlisted_buf = curbuf().id + unlisted_buf = curbuf() command('tabnew') insert('foo') - old_buf = curbuf().id - old_win = curwin().id + old_buf = curbuf() + old_win = curwin() end) describe('without splits, deleting the last listed buffer creates an empty buffer', function() local same_buf_float before_each(function() - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + api.nvim_set_current_win(old_win) + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) end) after_each(function() expect('') - eq(2, #meths.list_wins()) - eq(2, #meths.list_tabpages()) + eq(2, #api.nvim_list_wins()) + eq(2, #api.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, curwin().id) + api.nvim_buf_delete(old_buf, {force = true}) + eq(old_win, curwin()) end) it('if called from non-floating window in another tabpage', function() command('tab split') - eq(3, #meths.list_tabpages()) - meths.buf_delete(old_buf, {force = true}) + eq(3, #api.nvim_list_tabpages()) + api.nvim_buf_delete(old_buf, {force = true}) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) + api.nvim_set_current_win(same_buf_float) command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()') command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()') - meths.buf_delete(old_buf, {force = true}) + api.nvim_buf_delete(old_buf, {force = true}) eq(same_buf_float, eval('g:win_leave')) eq(old_win, eval('g:win_enter')) - eq(old_win, curwin().id) + eq(old_win, curwin()) end) end) describe('with splits, deleting the last listed buffer creates an empty buffer', function() local same_buf_float before_each(function() command('botright vsplit') - meths.set_current_buf(unlisted_buf) - meths.set_current_win(old_win) - same_buf_float = meths.open_win(old_buf, false, float_opts).id + api.nvim_set_current_buf(unlisted_buf) + api.nvim_set_current_win(old_win) + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) end) after_each(function() expect('') - eq(3, #meths.list_wins()) - eq(2, #meths.list_tabpages()) + eq(3, #api.nvim_list_wins()) + eq(2, #api.nvim_list_tabpages()) end) it('if called from non-floating window with the deleted buffer', function() - meths.buf_delete(old_buf, {force = true}) - eq(old_win, curwin().id) + api.nvim_buf_delete(old_buf, {force = true}) + eq(old_win, curwin()) end) it('if called from floating window with the deleted buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = true}) - eq(same_buf_float, curwin().id) + api.nvim_set_current_win(same_buf_float) + api.nvim_buf_delete(old_buf, {force = true}) + eq(same_buf_float, curwin()) end) end) end) @@ -753,48 +760,48 @@ describe('float window', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1} local old_tabpage, old_buf, old_win before_each(function() - old_tabpage = curtab().id + old_tabpage = curtab() insert('oldtab') command('tabnew') - old_buf = curbuf().id - old_win = curwin().id + old_buf = curbuf() + old_win = curwin() end) describe('closing the last non-floating window', function() describe('closes the tabpage when all floating windows are closeable', function() local same_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) end) after_each(function() - eq(old_tabpage, curtab().id) + eq(old_tabpage, curtab()) expect('oldtab') - eq(1, #meths.list_tabpages()) + eq(1, #api.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.win_close(old_win, false) + api.nvim_win_close(old_win, false) end) it('if called from floating window', function() - meths.set_current_win(same_buf_float) - meths.win_close(old_win, false) + api.nvim_set_current_win(same_buf_float) + api.nvim_win_close(old_win, false) end) end) describe('gives E5601 when there are non-closeable floating windows', function() local other_buf_float before_each(function() command('set nohidden') - local other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id + local other_buf = api.nvim_create_buf(true, false) + other_buf_float = api.nvim_open_win(other_buf, true, float_opts) insert('foo') - meths.set_current_win(old_win) + api.nvim_set_current_win(old_win) end) it('if called from non-floating window', function() eq('Vim:E5601: Cannot close window, only floating window would remain', - pcall_err(meths.win_close, old_win, false)) + pcall_err(api.nvim_win_close, old_win, false)) end) it('if called from floating window', function() - meths.set_current_win(other_buf_float) + api.nvim_set_current_win(other_buf_float) eq('Vim:E5601: Cannot close window, only floating window would remain', - pcall_err(meths.win_close, old_win, false)) + pcall_err(api.nvim_win_close, old_win, false)) end) end) end) @@ -802,27 +809,27 @@ describe('float window', function() describe('closes the tabpage when all floating windows are closeable', function() local same_buf_float, other_buf, other_buf_float before_each(function() - same_buf_float = meths.open_win(old_buf, false, float_opts).id - other_buf = meths.create_buf(true, false).id - other_buf_float = meths.open_win(other_buf, true, float_opts).id - meths.set_current_win(old_win) + same_buf_float = api.nvim_open_win(old_buf, false, float_opts) + other_buf = api.nvim_create_buf(true, false) + other_buf_float = api.nvim_open_win(other_buf, true, float_opts) + api.nvim_set_current_win(old_win) end) after_each(function() - eq(old_tabpage, curtab().id) + eq(old_tabpage, curtab()) expect('oldtab') - eq(1, #meths.list_tabpages()) + eq(1, #api.nvim_list_tabpages()) end) it('if called from non-floating window', function() - meths.buf_delete(old_buf, {force = false}) + api.nvim_buf_delete(old_buf, {force = false}) end) it('if called from floating window with the same buffer', function() - meths.set_current_win(same_buf_float) - meths.buf_delete(old_buf, {force = false}) + api.nvim_set_current_win(same_buf_float) + api.nvim_buf_delete(old_buf, {force = false}) end) -- TODO: this case is too hard to deal with pending('if called from floating window with another buffer', function() - meths.set_current_win(other_buf_float) - meths.buf_delete(old_buf, {force = false}) + api.nvim_set_current_win(other_buf_float) + api.nvim_buf_delete(old_buf, {force = false}) end) end) -- TODO: what to do when there are non-closeable floating windows? @@ -862,36 +869,27 @@ describe('float window', function() [24] = {foreground = Screen.colors.Black, background = Screen.colors.Grey80}; [25] = {blend = 100, background = Screen.colors.Gray0}; [26] = {blend = 80, background = Screen.colors.Gray0}; - [27] = {background = Screen.colors.LightGray}; - [28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGray}; + [27] = {foreground = Screen.colors.Black, background = Screen.colors.LightGrey}; + [28] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}; } screen:set_default_attr_ids(attrs) end) it('can be created and reconfigured', function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 5, true}, + [4]={1001, 'NW', 1, 2, 5, true}, } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -904,33 +902,23 @@ describe('float window', function() {0:~ }| {0:~ }{1: }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end - meths.win_set_config(win, {relative='editor', row=0, col=10}) + api.nvim_win_set_config(win, {relative='editor', row=0, col=10}) expected_pos[4][4] = 0 expected_pos[4][5] = 10 if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -941,43 +929,27 @@ describe('float window', function() screen:expect([[ ^ {1: } | {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end - meths.win_close(win, false) + api.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ]]) else screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end @@ -985,39 +957,29 @@ describe('float window', function() it('window position fixed', function() command('rightbelow 20vsplit') - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, { + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, { relative='win', width=15, height=2, row=2, col=10, anchor='NW', fixed=true}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]|*5 {5:[No Name] }{4:[No Name] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 5 {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 4, 2, 10, true}; + [5] = {1002, "NW", 4, 2, 10, true}; }} else screen:expect([[ @@ -1031,7 +993,7 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {fixed=false}) + api.nvim_win_set_config(win, {fixed=false}) if multigrid then screen:expect_unchanged() @@ -1055,29 +1017,20 @@ describe('float window', function() -- or something. command("set redrawdebug=compositor") command("set wd=1") - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 5, true}, + [4]={1001, 'NW', 1, 2, 5, true}, } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1090,33 +1043,23 @@ describe('float window', function() {0:~ }| {0:~ }{1: }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end - meths.win_set_config(win, {relative='editor', row=0, col=10}) + api.nvim_win_set_config(win, {relative='editor', row=0, col=10}) expected_pos[4][4] = 0 expected_pos[4][5] = 10 if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1127,84 +1070,70 @@ describe('float window', function() screen:expect([[ ^ {1: } | {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end - meths.win_close(win, false) + api.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ]]) else screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end end) it('return their configuration', function() - local buf = meths.create_buf(false, false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60}) + local buf = api.nvim_create_buf(false, false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=3, col=5, zindex=60}) local expected = {anchor='NW', col=5, external=false, focusable=true, height=2, relative='editor', row=3, width=20, zindex=60, hide=false} - eq(expected, meths.win_get_config(win)) + eq(expected, api.nvim_win_get_config(win)) + eq(true, exec_lua([[ + local expected, win = ... + local actual = vim.api.nvim_win_get_config(win) + for k,v in pairs(expected) do + if v ~= actual[k] then + error(k) + end + end + return true]], expected, win)) - eq({relative='', external=false, focusable=true, hide=false}, meths.win_get_config(0)) + eq({external=false, focusable=true, hide=false, relative='',split="left",width=40,height=6}, api.nvim_win_get_config(0)) if multigrid then - meths.win_set_config(win, {external=true, width=10, height=1}) - eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, meths.win_get_config(win)) + api.nvim_win_set_config(win, {external=true, width=10, height=1}) + eq({external=true,focusable=true,width=10,height=1,relative='',hide=false}, api.nvim_win_get_config(win)) end end) it('defaults to NormalFloat highlight and inherited options', function() command('set number') - command('hi NormalFloat guibg=#333333') + command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10}) + local win = api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {14: 1 }^x | {14: 2 }y | {14: 3 } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 @@ -1212,7 +1141,7 @@ describe('float window', function() {18: 2 }{15:y }| {18: 3 }{15: }| {16:~ }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ {14: 1 }^x | @@ -1225,41 +1154,30 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = api.nvim_create_buf(false, true) + api.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {14: 1 }^x | {14: 2 }y | {14: 3 } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 {18: 1 }{15: }| - {16:~ }| - {16:~ }| - {16:~ }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {16:~ }|*3 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ {14: 1 }^x | {14: 2 }y | {14: 3 } {18: 1 }{15: } | - {0:~ }{16:~ }{0: }| - {0:~ }{16:~ }{0: }| - {0:~ }{16:~ }{0: }| + {0:~ }{16:~ }{0: }|*3 | ]]) end @@ -1271,42 +1189,33 @@ describe('float window', function() command('set colorcolumn=1') command('set cursorline') command('set foldcolumn=1') - command('hi NormalFloat guibg=#333333') + command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + local win = api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 {15:x }| {15:y }| - {15: }| - {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {15: }|*2 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect{grid=[[ {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } {15:x } | {0:~ }{15:y }{0: }| - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }|*2 | ]]} end @@ -1317,20 +1226,13 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 @@ -1338,7 +1240,7 @@ describe('float window', function() {19: }{15:y }| {19: }{15: }| {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ @@ -1353,41 +1255,29 @@ describe('float window', function() end command('sign unplace 1 buffer=1') - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = api.nvim_create_buf(false, true) + api.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 - {15: }| - {15: }| - {15: }| - {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {15: }|*4 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } {15: } | - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }|*3 | ]]) end @@ -1399,42 +1289,33 @@ describe('float window', function() command('set colorcolumn=1') command('set cursorline') command('set foldcolumn=1') - command('hi NormalFloat guibg=#333333') + command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - local win = meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + local win = api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 {15:x }| {15:y }| - {15: }| - {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {15: }|*2 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect{grid=[[ {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } {15:x } | {0:~ }{15:y }{0: }| - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }|*2 | ]]} end @@ -1445,20 +1326,13 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{17:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 @@ -1466,7 +1340,7 @@ describe('float window', function() {19: }{15:y }| {19: }{15: }| {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ @@ -1481,41 +1355,29 @@ describe('float window', function() end command('sign unplace 1 buffer=1') - local buf = meths.create_buf(false, true) - meths.win_set_buf(win, buf) + local buf = api.nvim_create_buf(false, true) + api.nvim_win_set_buf(win, buf) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 - {15: }| - {15: }| - {15: }| - {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {15: }|*4 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect([[ {19: }{20: 1 }{22:^x}{21: }| {19: }{14: 2 }{22:y} | {19: }{14: 3 }{22: } {15: } | - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }|*3 | ]]) end @@ -1528,70 +1390,52 @@ describe('float window', function() command('set cursorline') command('set foldcolumn=1') command('set statuscolumn=%l%s%C') - command('hi NormalFloat guibg=#333333') + command('hi NormalFloat guibg=#333333 guifg=NONE') feed('ix<cr>y<cr><esc>gg') - meths.open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) + api.nvim_open_win(0, false, {relative='editor', width=20, height=4, row=4, col=10, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 {20:1}{19: }{20: }{22:^x}{21: }| {14:2}{19: }{14: }{22:y} | {14:3}{19: }{14: }{22: } | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 {15:x }| {15:y }| - {15: }| - {15: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 4, 10, true}}} + {15: }|*2 + ]], float_pos={[4] = {1001, "NW", 1, 4, 10, true}}} else screen:expect{grid=[[ {20:1}{19: }{20: }{22:^x}{21: }| {14:2}{19: }{14: }{22:y} | {14:3}{19: }{14: }{22: } {15:x } | {0:~ }{15:y }{0: }| - {0:~ }{15: }{0: }| - {0:~ }{15: }{0: }| + {0:~ }{15: }{0: }|*2 | ]]} end end) it('can have border', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"}) + local win = api.nvim_open_win(buf, false, {relative='editor', width=9, height=2, row=2, col=5, border="double"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1600,10 +1444,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1617,24 +1461,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="single"}) + api.nvim_win_set_config(win, {border="single"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1643,10 +1478,10 @@ describe('float window', function() {5:│}{1: BORDAA }{5:│}| {5:└─────────┘}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1660,24 +1495,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="rounded"}) + api.nvim_win_set_config(win, {border="rounded"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1686,10 +1512,10 @@ describe('float window', function() {5:│}{1: BORDAA }{5:│}| {5:╰─────────╯}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1703,24 +1529,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="solid"}) + api.nvim_win_set_config(win, {border="solid"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1729,10 +1546,10 @@ describe('float window', function() {5: }{1: BORDAA }{5: }| {5: }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1747,24 +1564,15 @@ describe('float window', function() end -- support: ascii char, UTF-8 char, composed char, highlight per char - meths.win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}}) + api.nvim_win_set_config(win, {border={"x", {"å", "ErrorMsg"}, {"\\"}, {"n̈̊", "Search"}}}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1773,10 +1581,10 @@ describe('float window', function() {17:n̈̊}{1: BORDAA }{17:n̈̊}| {5:\}{7:ååååååååå}{5:x}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1790,34 +1598,25 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {border="none"}) + api.nvim_win_set_config(win, {border="none"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1: halloj! }| {1: BORDAA }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1825,40 +1624,30 @@ describe('float window', function() {0:~ }| {0:~ }{1: halloj! }{0: }| {0:~ }{1: BORDAA }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end - meths.win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}}) + api.nvim_win_set_config(win, {border={"", "", "", ">", "", "", "", "<"}}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:<}{1: halloj! }{5:>}| {5:<}{1: BORDAA }{5:>}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1866,30 +1655,20 @@ describe('float window', function() {0:~ }| {0:~ }{5:<}{1: halloj! }{5:>}{0: }| {0:~ }{5:<}{1: BORDAA }{5:>}{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end - meths.win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}}) + api.nvim_win_set_config(win, {border={"", "_", "", "", "", "-", "", ""}}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -1898,10 +1677,10 @@ describe('float window', function() {1: BORDAA }| {5:---------}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1923,16 +1702,11 @@ describe('float window', function() of border shadow ]] - meths.win_set_config(win, {border="shadow"}) + api.nvim_win_set_config(win, {border="shadow"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 neeed some dummy | @@ -1948,10 +1722,10 @@ describe('float window', function() {1: BORDAA }{26: }| {25: }{26: }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 6, curline = 5, curcol = 0, linecount = 6, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -1967,13 +1741,13 @@ describe('float window', function() end) it('validates title title_pos', function() - local buf = meths.create_buf(false,false) + local buf = api.nvim_create_buf(false,false) eq("title requires border to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(api.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, title='Title', })) eq("title_pos requires title to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(api.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, border='single', title_pos='left', })) @@ -2001,13 +1775,13 @@ describe('float window', function() end) it('validates footer footer_pos', function() - local buf = meths.create_buf(false,false) + local buf = api.nvim_create_buf(false,false) eq("footer requires border to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(api.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, footer='Footer', })) eq("footer_pos requires footer to be set", - pcall_err(meths.open_win,buf, false, { + pcall_err(api.nvim_open_win,buf, false, { relative='editor', width=9, height=2, row=2, col=5, border='single', footer_pos='left', })) @@ -2035,10 +1809,10 @@ describe('float window', function() end) it('center aligned title longer than window width #25746', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = api.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "abcdefghijklmnopqrstuvwxyz",title_pos = "center", }) @@ -2046,20 +1820,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2068,10 +1833,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2085,15 +1850,15 @@ describe('float window', function() ]]} end - meths.win_close(win, false) + api.nvim_win_close(win, false) assert_alive() end) it('border with title', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = api.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "Left",title_pos = "left", }) @@ -2101,20 +1866,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2123,10 +1879,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2140,24 +1896,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Center",title_pos="center"}) + api.nvim_win_set_config(win, {title= "Center",title_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2166,10 +1913,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2183,24 +1930,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Right",title_pos="right"}) + api.nvim_win_set_config(win, {title= "Right",title_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2209,10 +1947,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2226,24 +1964,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"}) + api.nvim_win_set_config(win, {title= { {"🦄"},{"BB"}},title_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2252,10 +1981,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2271,10 +2000,10 @@ describe('float window', function() end) it('border with footer', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = api.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", footer = "Left",footer_pos = "left", }) @@ -2282,20 +2011,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2304,10 +2024,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚}{11:Left}{5:═════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2321,24 +2041,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= "Center",footer_pos="center"}) + api.nvim_win_set_config(win, {footer= "Center",footer_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2347,10 +2058,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═}{11:Center}{5:══╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2364,24 +2075,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= "Right",footer_pos="right"}) + api.nvim_win_set_config(win, {footer= "Right",footer_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2390,10 +2092,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚════}{11:Right}{5:╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2407,24 +2109,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"}) + api.nvim_win_set_config(win, {footer= { {"🦄"},{"BB"}},footer_pos="right"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2433,10 +2126,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════}🦄BB{5:╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2452,10 +2145,10 @@ describe('float window', function() end) it('border with title and footer', function() - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, { + local win = api.nvim_open_win(buf, false, { relative='editor', width=9, height=2, row=2, col=5, border="double", title = "Left", title_pos = "left", footer = "Right", footer_pos = "right", }) @@ -2463,20 +2156,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2485,10 +2169,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚════}{11:Right}{5:╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2502,24 +2186,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"}) + api.nvim_win_set_config(win, {title= "Center",title_pos="center",footer= "Center",footer_pos="center"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2528,10 +2203,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═}{11:Center}{5:══╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2545,24 +2220,15 @@ describe('float window', function() ]]} end - meths.win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"}) + api.nvim_win_set_config(win, {title= "Right",title_pos="right",footer= "Left",footer_pos="left"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2571,10 +2237,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚}{11:Left}{5:═════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2590,27 +2256,18 @@ describe('float window', function() command('hi B0 guibg=Red guifg=Black') command('hi B1 guifg=White') - meths.win_set_config(win, { + api.nvim_win_set_config(win, { title = {{"🦄"}, {"BB", {"B0", "B1"}}}, title_pos = "right", footer= {{"🦄"}, {"BB", {"B0", "B1"}}}, footer_pos = "right", }) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -2619,10 +2276,10 @@ describe('float window', function() {5:║}{1: BORDAA }{5:║}| {5:╚═════}🦄{7:BB}{5:╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true } + [4] = { 1001, "NW", 1, 2, 5, true } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2638,51 +2295,34 @@ describe('float window', function() end) it('terminates border on edge of viewport when window extends past viewport', function() - local buf = meths.create_buf(false, false) - meths.open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) + local buf = api.nvim_create_buf(false, false) + api.nvim_open_win(buf, false, {relative='editor', width=40, height=7, row=0, col=0, border="single", zindex=201}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌────────────────────────────────────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*6 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 0, true, 201 } + [4] = { 1001, "NW", 1, 0, 0, true, 201 } }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {5:^┌──────────────────────────────────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*4 {5:└──────────────────────────────────────┘}| ]]} end @@ -2690,35 +2330,20 @@ describe('float window', function() it('with border show popupmenu', function() screen:try_resize(40,10) - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ', 'abb acc ', ''}) - meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"}) + api.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5, border="double"}) feed 'G' if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 | ## grid 4 @@ -2728,10 +2353,10 @@ describe('float window', function() {5:║}{1:^ }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; + [4] = { 1001, "NW", 1, 0, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 2, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2740,10 +2365,7 @@ describe('float window', function() {0:~ }{5:║}{1:abb acc }{5:║}{0: }| {0:~ }{5:║}{1:^ }{5:║}{0: }| {0:~ }{5:╚═════════╝}{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end @@ -2752,26 +2374,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 {3:-- }{8:match 1 of 4} | ## grid 4 @@ -2786,11 +2393,11 @@ describe('float window', function() {1: abb }| {13: acc }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 5, true, 50 }; - [5] = { { id = -1 }, "NW", 4, 4, 0, false, 100 }; + [4] = { 1001, "NW", 1, 0, 5, true, 50 }; + [5] = { -1, "NW", 4, 4, 0, false, 100 }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 2, curcol = 3, linecount=3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2811,26 +2418,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 | ## grid 4 @@ -2840,10 +2432,10 @@ describe('float window', function() {5:║}{1:ac^c }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; + [4] = { 1001, "NW", 1, 0, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2852,10 +2444,7 @@ describe('float window', function() {0:~ }{5:║}{1:abb acc }{5:║}{0: }| {0:~ }{5:║}{1:ac^c }{5:║}{0: }| {0:~ }{5:╚═════════╝}{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end @@ -2869,26 +2458,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 :popup Test | ## grid 4 @@ -2902,11 +2476,11 @@ describe('float window', function() {1: bar }| {1: baz }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 0, 5, true }; - [5] = { { id = -1 }, "NW", 4, 4, 2, false, 250 }; + [4] = { 1001, "NW", 1, 0, 5, true }; + [5] = { -1, "NW", 4, 4, 2, false, 250 }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 2, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -2917,8 +2491,7 @@ describe('float window', function() {0:~ }{5:╚═}{1: foo }{5:═══╝}{0: }| {0:~ }{1: bar }{0: }| {0:~ }{1: baz }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 :popup Test | ]]} end @@ -2926,29 +2499,20 @@ describe('float window', function() it('show ruler of current floating window', function() command 'set ruler' - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {'aaa aab ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'aaa aab ', 'abb acc '}) - meths.open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5}) + api.nvim_open_win(buf, true, {relative='editor', width=9, height=3, row=0, col=5}) feed 'gg' if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 1,1 All | ## grid 4 @@ -2956,19 +2520,17 @@ describe('float window', function() {1:abb acc }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {1:^aaa aab } | {0:~ }{1:abb acc }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 1,1 All | ]]} end @@ -2977,20 +2539,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 1,5 All | ## grid 4 @@ -2998,19 +2551,17 @@ describe('float window', function() {1:abb acc }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 4, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {1:aaa ^aab } | {0:~ }{1:abb acc }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 1,5 All | ]]} end @@ -3018,44 +2569,31 @@ describe('float window', function() it("correct ruler position in current float with 'rulerformat' set", function() command 'set ruler rulerformat=fish:<><' - meths.open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5}) + api.nvim_open_win(0, true, {relative='editor', width=9, height=3, row=0, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 fish:<>< | ## grid 4 {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {1:^ } | - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }{2:~ }{0: }|*2 + {0:~ }|*3 fish:<>< | ]]} end @@ -3064,60 +2602,40 @@ describe('float window', function() it('does not show ruler of not-last current float during ins-completion', function() screen:try_resize(50,9) command 'set ruler showmode' - meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0}) - meths.open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5}) + api.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=0}) + api.nvim_open_win(0, false, {relative='editor', width=3, height=3, row=0, col=5}) feed '<c-w>w' - neq('', meths.win_get_config(0).relative) - neq(funcs.winnr '$', funcs.winnr()) + neq('', api.nvim_win_get_config(0).relative) + neq(fn.winnr '$', fn.winnr()) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 0,0-1 All | ## grid 4 {1: }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ## grid 5 {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; - [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50}; + [5] = {1002, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {1: } {1:^ } | - {2:~ }{0: }{2:~ }{0: }| - {2:~ }{0: }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {2:~ }{0: }{2:~ }{0: }|*2 + {0:~ }|*5 0,0-1 All | ]]} end @@ -3125,52 +2643,32 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} | ## grid 4 {1: }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ## grid 5 {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 0, 5, true, 50}; - [4] = {{id = 1001}, "NW", 1, 0, 0, true, 50}; + [5] = {1002, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ {1: } {1:^ } | - {2:~ }{0: }{2:~ }{0: }| - {2:~ }{0: }{2:~ }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {2:~ }{0: }{2:~ }{0: }|*2 + {0:~ }|*5 {3:-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)} | ]]} end @@ -3178,111 +2676,72 @@ describe('float window', function() it('can have minimum size', function() insert("the background text") - local buf = meths.create_buf(false, true) - meths.buf_set_lines(buf, 0, -1, true, {'x'}) - local win = meths.open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false}) + local buf = api.nvim_create_buf(false, true) + api.nvim_buf_set_lines(buf, 0, -1, true, {'x'}) + local win = api.nvim_open_win(buf, false, {relative='win', width=1, height=1, row=0, col=4, focusable=false}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 the background tex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1:x}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 2, 0, 4, false} + [4] = {1001, "NW", 2, 0, 4, false} }} else screen:expect([[ the {1:x}ackground tex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end - meths.win_set_config(win, {relative='win', row=0, col=15}) + api.nvim_win_set_config(win, {relative='win', row=0, col=15}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 the background tex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1:x}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 2, 0, 15, false} + [4] = {1001, "NW", 2, 0, 15, false} }} else screen:expect([[ the background {1:x}ex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end - meths.win_close(win,false) + api.nvim_win_close(win,false) if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 the background tex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ]]) else screen:expect([[ the background tex^t | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end @@ -3303,23 +2762,19 @@ describe('float window', function() command('sargument 6') local float_opts = { relative = 'editor', row = 6, col = 0, width = 40, height = 1 } - meths.win_set_config(w3, float_opts) - meths.win_set_config(w4, float_opts) + api.nvim_win_set_config(w3, float_opts) + api.nvim_win_set_config(w4, float_opts) command('wincmd =') if multigrid then screen:expect{grid=[[ ## grid 1 - [8:----------------------------------------]| - [8:----------------------------------------]| + [8:----------------------------------------]|*2 {4:X6 }| - [7:----------------------------------------]| - [7:----------------------------------------]| + [7:----------------------------------------]|*2 {5:X5 }| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*2 {5:X2 }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:X1 }| [3:----------------------------------------]| ## grid 2 @@ -3341,15 +2796,15 @@ describe('float window', function() ^ | {0:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 6, 0, true, 50}; - [6] = {{id = 1003}, "NW", 1, 6, 0, true, 50}; + [5] = {1002, "NW", 1, 6, 0, true, 50}; + [6] = {1003, "NW", 1, 6, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [6] = {win = {id = 1003}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [7] = {win = {id = 1004}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [8] = {win = {id = 1005}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = 1003, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [7] = {win = 1004, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [8] = {win = 1005, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -3401,12 +2856,12 @@ describe('float window', function() ## grid 10 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [7] = {win = {id = 1004}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [8] = {win = {id = 1005}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [9] = {win = {id = 1006}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [10] = {win = {id = 1007}, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [7] = {win = 1004, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [8] = {win = 1005, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [9] = {win = 1006, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [10] = {win = 1007, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -3437,47 +2892,47 @@ describe('float window', function() end) it('API has proper error messages', function() - local buf = meths.create_buf(false,false) + local buf = api.nvim_create_buf(false,false) eq("Invalid key: 'bork'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,bork=true})) - eq("'win' key is only valid with relative='win'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,bork=true})) + eq("'win' key is only valid with relative='win' and relative=''", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,win=0})) + eq("floating windows cannot have 'vertical'", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,vertical=true})) + eq("floating windows cannot have 'split'", + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,split="left"})) eq("Only one of 'relative' and 'external' must be used", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,external=true})) eq("Invalid value of 'relative' key", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='shell',row=0,col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='shell',row=0,col=0})) eq("Invalid value of 'anchor' key", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor',row=0,col=0,anchor='bottom'})) eq("'relative' requires 'row'/'col' or 'bufpos'", - pcall_err(meths.open_win,buf, false, {width=20,height=2,relative='editor'})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=2,relative='editor'})) eq("'width' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=-1,height=2,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=-1,relative='editor', row=0, col=0})) eq("'height' key must be a positive Integer", - pcall_err(meths.open_win,buf, false, {width=20,height=0,relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {width=20,height=0,relative='editor', row=0, col=0})) eq("Must specify 'width'", - pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0})) + pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0})) eq("Must specify 'height'", - pcall_err(meths.open_win,buf, false, {relative='editor', row=0, col=0, width=2})) + pcall_err(api.nvim_open_win, buf, false, {relative='editor', row=0, col=0, width=2})) end) it('can be placed relative window or cursor', function() screen:try_resize(40,9) - meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text'}) + api.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text'}) feed('gge') - local oldwin = meths.get_current_win() + local oldwin = api.nvim_get_current_win() command('below split') if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3505,19 +2960,15 @@ describe('float window', function() ]]) end - local buf = meths.create_buf(false,false) + local buf = api.nvim_create_buf(false,false) -- no 'win' arg, relative default window - local win = meths.open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10}) + local win = api.nvim_open_win(buf, false, {relative='win', width=20, height=2, row=0, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3534,7 +2985,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 4, 0, 10, true} + [5] = {1002, "NW", 4, 0, 10, true} }} else screen:expect([[ @@ -3550,17 +3001,13 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=1, col=-2}) + api.nvim_win_set_config(win, {relative='cursor', row=1, col=-2}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3577,7 +3024,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 4, 1, 1, true} + [5] = {1002, "NW", 4, 1, 1, true} }} else screen:expect([[ @@ -3593,17 +3040,13 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'}) + api.nvim_win_set_config(win, {relative='cursor', row=0, col=0, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3620,7 +3063,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "SW", 4, 0, 3, true} + [5] = {1002, "SW", 4, 0, 3, true} }} else screen:expect([[ @@ -3636,17 +3079,13 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) + api.nvim_win_set_config(win, {relative='win', win=oldwin, row=1, col=10, anchor='NW'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3663,7 +3102,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 2, 1, 10, true} + [5] = {1002, "NW", 2, 1, 10, true} }} else screen:expect([[ @@ -3679,17 +3118,13 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) + api.nvim_win_set_config(win, {relative='win', win=oldwin, row=3, col=39, anchor='SE'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3706,7 +3141,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "SE", 2, 3, 39, true} + [5] = {1002, "SE", 2, 3, 39, true} }} else screen:expect([[ @@ -3722,17 +3157,13 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'}) + api.nvim_win_set_config(win, {relative='win', win=0, row=0, col=50, anchor='NE'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*3 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -3749,7 +3180,7 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [5] = {{id = 1002}, "NE", 4, 0, 50, true} + [5] = {1002, "NE", 4, 0, 50, true} }, win_viewport = { [2] = { topline = 0, @@ -3758,7 +3189,7 @@ describe('float window', function() curcol = 3, linecount = 2, sum_scroll_delta = 0, - win = { id = 1000 }, + win = 1000, }, [4] = { topline = 0, @@ -3767,7 +3198,7 @@ describe('float window', function() curcol = 3, linecount = 2, sum_scroll_delta = 0, - win = { id = 1001 } + win = 1001 }, [5] = { topline = 0, @@ -3776,7 +3207,7 @@ describe('float window', function() curcol = 0, linecount = 1, sum_scroll_delta = 0, - win = { id = 1002 } + win = 1002 } }} else @@ -3796,108 +3227,78 @@ describe('float window', function() it('always anchor to corner including border', function() screen:try_resize(40,13) - meths.buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'}) + api.nvim_buf_set_lines(0, 0, -1, true, {'just some example text', 'some more example text'}) feed('ggeee') command('below split') if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*5 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ]]) else screen:expect([[ just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {5:[No Name] [+] }| just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:[No Name] [+] }| | ]]) end - local buf = meths.create_buf(false, false) - meths.buf_set_lines(buf, 0, -1, true, {' halloj! ', + local buf = api.nvim_create_buf(false, false) + api.nvim_buf_set_lines(buf, 0, -1, true, {' halloj! ', ' BORDAA '}) - local win = meths.open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"}) + local win = api.nvim_open_win(buf, false, {relative='cursor', width=9, height=2, row=1, col=-2, border="double"}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*5 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = {{id = 1002}, "NW", 4, 1, 14, true} + [5] = {1002, "NW", 4, 1, 14, true} }} else screen:expect([[ just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {5:[No Name] [+] }| just some exampl^e text | some more exam{5:╔═════════╗} | @@ -3909,52 +3310,38 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'}) + api.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='NE'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*5 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = {{id = 1002}, "NE", 4, 0, 14, true} + [5] = {1002, "NE", 4, 0, 14, true} }} else screen:expect([[ just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {5:[No Name] [+] }| jus{5:╔═════════╗}pl^e text | som{5:║}{1: halloj! }{5:║}ple text | @@ -3966,44 +3353,32 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'}) + api.nvim_win_set_config(win, {relative='cursor', row=1, col=-2, anchor='SE'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*5 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = {{id = 1002}, "SE", 4, 1, 14, true} + [5] = {1002, "SE", 4, 1, 14, true} }} else screen:expect([[ @@ -4015,52 +3390,38 @@ describe('float window', function() {5:[No║}{1: BORDAA }{5:║ }| jus{5:╚═════════╝}pl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:[No Name] [+] }| | ]]) end - meths.win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'}) + api.nvim_win_set_config(win, {relative='cursor', row=0, col=-2, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*5 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 just some example text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 {5:╔═════════╗}| {5:║}{1: halloj! }{5:║}| {5:║}{1: BORDAA }{5:║}| {5:╚═════════╝}| ]], float_pos={ - [5] = {{id = 1002}, "SW", 4, 0, 14, true} + [5] = {1002, "SW", 4, 0, 14, true} }} else screen:expect([[ @@ -4072,9 +3433,7 @@ describe('float window', function() {5:[No Name] [+] ╚═════════╝ }| just some exampl^e text | some more example text | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:[No Name] [+] }| | ]]) @@ -4121,20 +3480,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 - | - | - | + |*3 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 ## grid 3 | ## grid 5 @@ -4154,14 +3505,14 @@ describe('float window', function() ## grid 12 {1:8 }| ]], float_pos={ - [5] = {{id = 1002}, "NW", 1, 1, 10, true, 50}; - [6] = {{id = 1003}, "NW", 1, 1, 30, true, 50}; - [7] = {{id = 1004}, "NE", 5, 1, 0, true, 50}; - [8] = {{id = 1005}, "NE", 6, 1, 0, true, 50}; - [9] = {{id = 1006}, "SE", 7, 0, 0, true, 50}; - [10] = {{id = 1007}, "SE", 8, 0, 0, true, 50}; - [11] = {{id = 1008}, "SW", 9, 0, 5, true, 50}; - [12] = {{id = 1009}, "SW", 10, 0, 5, true, 50}; + [5] = {1002, "NW", 1, 1, 10, true, 50}; + [6] = {1003, "NW", 1, 1, 30, true, 50}; + [7] = {1004, "NE", 5, 1, 0, true, 50}; + [8] = {1005, "NE", 6, 1, 0, true, 50}; + [9] = {1006, "SE", 7, 0, 0, true, 50}; + [10] = {1007, "SE", 8, 0, 0, true, 50}; + [11] = {1008, "SW", 9, 0, 5, true, 50}; + [12] = {1009, "SW", 10, 0, 5, true, 50}; }} else screen:expect([[ @@ -4169,8 +3520,7 @@ describe('float window', function() {1:5 } {1:1 } {1:6 } {1:2 } | {1:3 } {1:4 } | ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -4197,20 +3547,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 - | - | - | + |*3 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 ## grid 3 | ## grid 5 @@ -4230,14 +3572,14 @@ describe('float window', function() ## grid 12 {1:8 }| ]], float_pos={ - [5] = {{id = 1002}, "NE", 8, 1, 0, true, 50}; - [6] = {{id = 1003}, "NE", 12, 1, 0, true, 50}; - [7] = {{id = 1004}, "SE", 5, 0, 0, true, 50}; - [8] = {{id = 1005}, "NW", 1, 1, 30, true, 50}; - [9] = {{id = 1006}, "SW", 10, 0, 5, true, 50}; - [10] = {{id = 1007}, "SE", 6, 0, 0, true, 50}; - [11] = {{id = 1008}, "SW", 7, 0, 5, true, 50}; - [12] = {{id = 1009}, "NW", 1, 1, 10, true, 50}; + [5] = {1002, "NE", 8, 1, 0, true, 50}; + [6] = {1003, "NE", 12, 1, 0, true, 50}; + [7] = {1004, "SE", 5, 0, 0, true, 50}; + [8] = {1005, "NW", 1, 1, 30, true, 50}; + [9] = {1006, "SW", 10, 0, 5, true, 50}; + [10] = {1007, "SE", 6, 0, 0, true, 50}; + [11] = {1008, "SW", 7, 0, 5, true, 50}; + [12] = {1009, "NW", 1, 1, 10, true, 50}; }} else screen:expect([[ @@ -4245,8 +3587,7 @@ describe('float window', function() {1:6 } {1:8 } {1:3 } {1:4 } | {1:2 } {1:1 } | ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -4275,15 +3616,12 @@ describe('float window', function() it('can be placed relative text in a window', function() screen:try_resize(30,5) - local firstwin = meths.get_current_win().id - meths.buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'}) + local firstwin = api.nvim_get_current_win() + api.nvim_buf_set_lines(0, 0, -1, true, {'just some', 'example text that is wider than the window', '', '', 'more text'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*4 [3:------------------------------]| ## grid 2 ^just some | @@ -4298,22 +3636,18 @@ describe('float window', function() ^just some | example text that is wider tha| n the window | - | - | + |*2 ]]} end - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'some info!'}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'some info!'}) - local win = meths.open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}}) + local win = api.nvim_open_win(buf, false, {relative='win', width=12, height=1, bufpos={1,32}}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*4 [3:------------------------------]| ## grid 2 ^just some | @@ -4325,7 +3659,7 @@ describe('float window', function() ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 3, 2, true } + [4] = { 1001, "NW", 2, 3, 2, true } }} else screen:expect{grid=[[ @@ -4337,36 +3671,31 @@ describe('float window', function() ]]} end eq({relative='win', width=12, height=1, bufpos={1,32}, anchor='NW', hide=false, - external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, meths.win_get_config(win)) + external=false, col=0, row=1, win=firstwin, focusable=true, zindex=50}, api.nvim_win_get_config(win)) feed('<c-e>') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*4 [3:------------------------------]| ## grid 2 ^example text that is wider tha| n the window | - | - | + |*2 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 2, 2, true }, + [4] = { 1001, "NW", 2, 2, 2, true }, }} else screen:expect{grid=[[ ^example text that is wider tha| n the window | {1:some info! } | - | - | + |*2 ]]} end @@ -4375,22 +3704,18 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*4 [3:---------------------------------------------]| ## grid 2 ^example text that is wider than the window | - | - | + |*2 more text | ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 1, 32, true } + [4] = { 1001, "NW", 2, 1, 32, true } }} else -- note: appears misaligned due to cursor @@ -4407,32 +3732,20 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*9 [3:-------------------------]| ## grid 2 ^example text that is wide| r than the window | - | - | + |*2 more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 2, 7, true } + [4] = { 1001, "NW", 2, 2, 7, true } }} else screen:expect{grid=[[ @@ -4441,56 +3754,37 @@ describe('float window', function() {1:some info! } | | more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end - meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'}) + api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='SW'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*9 [3:-------------------------]| ## grid 2 ^example text that is wide| r than the window | - | - | + |*2 more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "SW", 2, 1, 7, true } + [4] = { 1001, "SW", 2, 1, 7, true } }} else screen:expect{grid=[[ ^example{1:some info! }s wide| r than the window | - | - | + |*2 more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end @@ -4500,15 +3794,7 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| - [2:----]{5:│}[5:--------------------]| + [2:----]{5:│}[5:--------------------]|*9 [3:-------------------------]| ## grid 2 exam| @@ -4526,16 +3812,9 @@ describe('float window', function() {1:some info! }| ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ]], float_pos={ - [4] = { { id = 1001 }, "SW", 2, 8, 0, true } + [4] = { 1001, "SW", 2, 8, 0, true } }} else screen:expect{grid=[[ @@ -4553,36 +3832,24 @@ describe('float window', function() end command('close') - meths.win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2}) + api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, anchor='NW', col=-2}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*9 [3:-------------------------]| ## grid 2 ^example text that is wide| r than the window | - | - | + |*2 more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 2, 5, true } + [4] = { 1001, "NW", 2, 2, 5, true } }} else screen:expect{grid=[[ @@ -4591,44 +3858,29 @@ describe('float window', function() {1:some info! } | | more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end - meths.win_set_config(win, {relative='win', bufpos={1,32}, row=2}) + api.nvim_win_set_config(win, {relative='win', bufpos={1,32}, row=2}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*9 [3:-------------------------]| ## grid 2 ^example text that is wide| r than the window | - | - | + |*2 more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 3, 7, true } + [4] = { 1001, "NW", 2, 3, 7, true } }} else screen:expect{grid=[[ @@ -4637,10 +3889,7 @@ describe('float window', function() | {1:some info! } | more text | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]} end @@ -4649,44 +3898,24 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*9 [3:-------------------------]| ## grid 2 {28:^+-- 5 lines: just some··}| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 | ## grid 4 {1:some info! }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 2, 2, 0, true } + [4] = { 1001, "NW", 2, 2, 0, true } }} else screen:expect{grid=[[ {28:^+-- 5 lines: just some··}| {0:~ }| {1:some info! }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]} end @@ -4699,57 +3928,44 @@ describe('float window', function() if multigrid then screen:expect([[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*4 [3:------------------------------]| ## grid 2 that is wider than the windo^w | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ]]) else screen:expect([[ that is wider than the windo^w | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end - local buf = meths.create_buf(false,true) - meths.buf_set_lines(buf, 0, -1, true, {'some floaty text'}) - meths.open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1}) + local buf = api.nvim_create_buf(false,true) + api.nvim_buf_set_lines(buf, 0, -1, true, {'some floaty text'}) + api.nvim_open_win(buf, false, {relative='editor', width=20, height=1, row=3, col=1}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*4 [3:------------------------------]| ## grid 2 that is wider than the windo^w | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 {1:some floaty text }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 3, 1, true} + [4] = {1001, "NW", 1, 3, 1, true} }} else screen:expect([[ that is wider than the windo^w | - {0:~ }| - {0:~ }| + {0:~ }|*2 {0:~}{1:some floaty text }{0: }| | ]]) @@ -4763,19 +3979,15 @@ describe('float window', function() local screen2 = Screen.new(40,7) screen2:attach(nil, session2) screen2:set_default_attr_ids(attrs) - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + api.nvim_open_win(buf, true, {relative='editor', width=20, height=2, row=2, col=5}) local expected_pos = { - [2]={{id=1001}, 'NW', 1, 2, 5} + [2]={1001, 'NW', 1, 2, 5} } screen:expect{grid=[[ ## grid 1 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ## grid 2 {1:^ }| @@ -4786,8 +3998,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^ }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -4795,29 +4006,20 @@ describe('float window', function() it('handles resized screen', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) - local win = meths.open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'such', 'very', 'float'}) + local win = api.nvim_open_win(buf, false, {relative='editor', width=15, height=4, row=2, col=10}) local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 10, true}, + [4]={1001, 'NW', 1, 2, 10, true}, } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -4842,16 +4044,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*4 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 3 | ## grid 4 @@ -4874,14 +4071,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*3 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 ## grid 3 | ## grid 4 @@ -4903,8 +4097,7 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 [3:----------------------------------------]| ## grid 2 ^ | @@ -4928,8 +4121,7 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 [3:----------------------------------------]| ## grid 2 | @@ -4954,20 +4146,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -4988,25 +4171,16 @@ describe('float window', function() ]]) end - meths.win_set_config(win, {height=3}) + api.nvim_win_set_config(win, {height=3}) feed('gg') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5030,20 +4204,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------]| - [2:--------------------------]| - [2:--------------------------]| - [2:--------------------------]| - [2:--------------------------]| - [2:--------------------------]| + [2:--------------------------]|*6 [3:--------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5067,20 +4232,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*6 [3:-------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5104,20 +4260,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------------------]| - [2:------------------------]| - [2:------------------------]| - [2:------------------------]| - [2:------------------------]| - [2:------------------------]| + [2:------------------------]|*6 [3:------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5141,20 +4288,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------]| - [2:----------------]| - [2:----------------]| - [2:----------------]| - [2:----------------]| - [2:----------------]| + [2:----------------]|*6 [3:----------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5178,20 +4316,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:---------------]| - [2:---------------]| - [2:---------------]| - [2:---------------]| - [2:---------------]| - [2:---------------]| + [2:---------------]|*6 [3:---------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5215,20 +4344,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------]| - [2:--------------]| - [2:--------------]| - [2:--------------]| - [2:--------------]| - [2:--------------]| + [2:--------------]|*6 [3:--------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5252,20 +4372,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:------------]| - [2:------------]| - [2:------------]| - [2:------------]| - [2:------------]| - [2:------------]| + [2:------------]|*6 [3:------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5312,20 +4423,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -5348,14 +4450,14 @@ describe('float window', function() it('does not crash with inccommand #9379', function() local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 0, true}, + [4]={1001, 'NW', 1, 2, 0, true}, } command("set inccommand=split") command("set laststatus=2") - local buf = meths.create_buf(false,false) - meths.open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0}) + local buf = api.nvim_create_buf(false,false) + api.nvim_open_win(buf, true, {relative='editor', width=30, height=3, row=2, col=0}) insert([[ foo @@ -5365,19 +4467,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -5402,11 +4497,7 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[Preview] }| [3:----------------------------------------]| ## grid 2 @@ -5435,19 +4526,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -5469,52 +4553,39 @@ describe('float window', function() end) it('does not crash when set cmdheight #9680', function() - local buf = meths.create_buf(false,false) - meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) command("set cmdheight=2") - eq(1, meths.eval('1')) + eq(1, api.nvim_eval('1')) end) describe('and completion', function() before_each(function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}).id - meths.set_option_value('winhl', 'Normal:ErrorMsg', {win=win}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, true, {relative='editor', width=12, height=4, row=2, col=5}) + api.nvim_set_option_value('winhl', 'Normal:ErrorMsg', {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7:^ }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else screen:expect([[ | {0:~ }| {0:~ }{7:^ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 | ]]) end @@ -5522,38 +4593,27 @@ describe('float window', function() it('with builtin popupmenu', function() feed('ix ') - funcs.complete(3, {'aa', 'word', 'longtext'}) + fn.complete(3, {'aa', 'word', 'longtext'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa^ }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ## grid 5 {13: aa }| {1: word }| {1: longtext }| ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50}, - [5] = {{ id = -1 }, "NW", 4, 1, 1, false, 100} + [4] = {1001, "NW", 1, 2, 5, true, 50}, + [5] = {-1, "NW", 4, 1, 1, false, 100} }} else screen:expect([[ @@ -5571,29 +4631,18 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7:x a^a }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else @@ -5601,46 +4650,33 @@ describe('float window', function() | {0:~ }| {0:~ }{7:x a^a }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 | ]]) end feed('<c-w>wi') - funcs.complete(1, {'xx', 'yy', 'zz'}) + fn.complete(1, {'xx', 'yy', 'zz'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 xx^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ## grid 5 {13:xx }| {1:yy }| {1:zz }| ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true, 50}, - [5] = {{ id = -1 }, "NW", 2, 1, 0, false, 100} + [4] = {1001, "NW", 1, 2, 5, true, 50}, + [5] = {-1, "NW", 2, 1, 0, false, 100} }} else screen:expect([[ @@ -5648,8 +4684,7 @@ describe('float window', function() {13:xx }{0: }| {1:yy }{7: }{0: }| {1:zz }{12: }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*2 {3:-- INSERT --} | ]]) end @@ -5658,38 +4693,25 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 xx^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else screen:expect([[ xx^ | {0:~ }| {0:~ }{7:x aa }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 {3:-- INSERT --} | ]]) end @@ -5701,33 +4723,22 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sign un^ | ## grid 4 {7: }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ## grid 5 {1: undefine }| {1: unplace }| ]], float_pos={ - [5] = {{id = -1}, "SW", 1, 6, 5, false, 250}; - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; + [5] = {-1, "SW", 1, 6, 5, false, 250}; + [4] = {1001, "NW", 1, 2, 5, true, 50}; }} else screen:expect{grid=[[ @@ -5745,34 +4756,23 @@ describe('float window', function() it('with ext_popupmenu', function() screen:set_option('ext_popupmenu', true) feed('ix ') - funcs.complete(3, {'aa', 'word', 'longtext'}) + fn.complete(3, {'aa', 'word', 'longtext'}) local items = {{"aa", "", "", ""}, {"word", "", "", ""}, {"longtext", "", "", ""}} if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa^ }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }, popupmenu={ anchor = {4, 0, 2}, items = items, pos = 0 }} @@ -5781,9 +4781,7 @@ describe('float window', function() | {0:~ }| {0:~ }{7:x aa^ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 {3:-- INSERT --} | ]], popupmenu={ anchor = {1, 2, 7}, items = items, pos = 0 @@ -5794,71 +4792,47 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7:x a^a }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else screen:expect([[ | {0:~ }| {0:~ }{7:x a^a }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 | ]]) end feed('<c-w>wi') - funcs.complete(1, {'xx', 'yy', 'zz'}) + fn.complete(1, {'xx', 'yy', 'zz'}) items = {{"xx", "", "", ""}, {"yy", "", "", ""}, {"zz", "", "", ""}} if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 xx^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }, popupmenu={ anchor = {2, 0, 0}, items = items, pos = 0 }} @@ -5867,9 +4841,7 @@ describe('float window', function() xx^ | {0:~ }| {0:~ }{7:x aa }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 {3:-- INSERT --} | ]], popupmenu={ anchor = {1, 0, 0}, items = items, pos = 0 @@ -5880,38 +4852,25 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 xx^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 {7:x aa }| - {12:~ }| - {12:~ }| - {12:~ }| + {12:~ }|*3 ]], float_pos={ - [4] = {{ id = 1001 }, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else screen:expect([[ xx^ | {0:~ }| {0:~ }{7:x aa }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| - {0:~ }{12:~ }{0: }| + {0:~ }{12:~ }{0: }|*3 {3:-- INSERT --} | ]]) end @@ -5921,26 +4880,17 @@ describe('float window', function() describe('float shown after pum', function() local win before_each(function() - command('hi NormalFloat guibg=#333333') + command('hi NormalFloat guibg=#333333 guifg=NONE') feed('i') - funcs.complete(1, {'aa', 'word', 'longtext'}) + fn.complete(1, {'aa', 'word', 'longtext'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 @@ -5948,7 +4898,7 @@ describe('float window', function() {1:word }| {1:longtext }| ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}} + [4] = {-1, "NW", 2, 1, 0, false, 100}} } else screen:expect([[ @@ -5956,32 +4906,22 @@ describe('float window', function() {13:aa }{0: }| {1:word }{0: }| {1:longtext }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end - local buf = meths.create_buf(false,true) - meths.buf_set_lines(buf,0,-1,true,{"some info", "about item"}) - win = meths.open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10}) + local buf = api.nvim_create_buf(false,true) + api.nvim_buf_set_lines(buf,0,-1,true,{"some info", "about item"}) + win = api.nvim_open_win(buf, false, {relative='cursor', width=12, height=2, row=1, col=10}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 @@ -5992,8 +4932,8 @@ describe('float window', function() {15:some info }| {15:about item }| ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}, - [5] = {{id = 1001}, "NW", 2, 1, 12, true, 50}, + [4] = {-1, "NW", 2, 1, 0, false, 100}, + [5] = {1001, "NW", 2, 1, 12, true, 50}, }} else screen:expect([[ @@ -6001,8 +4941,7 @@ describe('float window', function() {13:aa }{15:e info }{0: }| {1:word }{15:ut item }{0: }| {1:longtext }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end @@ -6013,93 +4952,60 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 5 {15:some info }| {15:about item }| ]], float_pos={ - [5] = {{id = 1001}, "NW", 2, 1, 12, true}, + [5] = {1001, "NW", 2, 1, 12, true}, }} else screen:expect([[ aa^ | {0:~ }{15:some info }{0: }| {0:~ }{15:about item }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:-- INSERT --} | ]]) end - meths.win_close(win, false) + api.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ]]) else screen:expect([[ aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) end end) it('and close float first', function() - meths.win_close(win, false) + api.nvim_win_close(win, false) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 @@ -6107,7 +5013,7 @@ describe('float window', function() {1:word }| {1:longtext }| ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 1, 0, false, 100}, + [4] = {-1, "NW", 2, 1, 0, false, 100}, }} else screen:expect([[ @@ -6115,8 +5021,7 @@ describe('float window', function() {13:aa }{0: }| {1:word }{0: }| {1:longtext }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end @@ -6125,31 +5030,18 @@ describe('float window', function() if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ]]) else screen:expect([[ aa^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {3:-- INSERT --} | ]]) end @@ -6157,38 +5049,29 @@ describe('float window', function() end) it("can use Normal as background", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf,0,-1,true,{"here", "float"}) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value('winhl', 'Normal:Normal', {win=win}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf,0,-1,true,{"here", "float"}) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + api.nvim_set_option_value('winhl', 'Normal:Normal', {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 here | float | ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; + [4] = {1001, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -6196,8 +5079,7 @@ describe('float window', function() {0:~ }| {0:~ }here {0: }| {0:~ }float {0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end @@ -6210,30 +5092,21 @@ describe('float window', function() -- the default, but be explicit: command("set laststatus=1") command("set hidden") - meths.buf_set_lines(0,0,-1,true,{"x"}) - local buf = meths.create_buf(false,false) - win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.buf_set_lines(buf,0,-1,true,{"y"}) + api.nvim_buf_set_lines(0,0,-1,true,{"x"}) + local buf = api.nvim_create_buf(false,false) + win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + api.nvim_buf_set_lines(buf,0,-1,true,{"y"}) expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 5, true} + [4]={1001, 'NW', 1, 2, 5, true} } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6246,8 +5119,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6258,20 +5130,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6284,8 +5147,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6294,20 +5156,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6320,34 +5173,24 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end end) it("w with focusable=false", function() - meths.win_set_config(win, {focusable=false}) + api.nvim_win_set_config(win, {focusable=false}) expected_pos[4][6] = false feed("<c-w>wi") -- i to provoke redraw if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 @@ -6360,8 +5203,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end @@ -6370,20 +5212,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6396,8 +5229,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6408,20 +5240,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6434,8 +5257,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6444,20 +5266,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6470,8 +5283,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6479,23 +5291,14 @@ describe('float window', function() it("focus by mouse", function() if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6503,36 +5306,26 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 2, 5) + api.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect([[ x | {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6540,41 +5333,32 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ ^x | {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end end) it("focus by mouse (focusable=false)", function() - meths.win_set_config(win, {focusable=false}) - meths.buf_set_lines(0, -1, -1, true, {"a"}) + api.nvim_win_set_config(win, {focusable=false}) + api.nvim_buf_set_lines(0, -1, -1, true, {"a"}) expected_pos[4][6] = false if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | a | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -6582,36 +5366,27 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos} else - meths.input_mouse('left', 'press', '', 0, 2, 5) + api.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect([[ x | ^a | {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | a | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -6619,14 +5394,13 @@ describe('float window', function() {2:~ }| ]], float_pos=expected_pos, unchanged=true} else - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ ^x | a | {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6637,20 +5411,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- INSERT --} | ## grid 4 @@ -6663,8 +5428,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end @@ -6673,20 +5437,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6699,8 +5454,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6709,20 +5463,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6735,8 +5480,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6748,20 +5492,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6774,8 +5509,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6784,34 +5518,23 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1:^y }| - {2:~ }| - {2:~ }| + {2:~ }|*2 ]], float_pos=expected_pos} else screen:expect([[ x | {0:~ }| {0:~ }{1:^y }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }|*2 {0:~ }| | ]]) @@ -6821,20 +5544,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6845,9 +5559,7 @@ describe('float window', function() x | {0:~ }| {0:~ }{1:^y }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end @@ -6856,36 +5568,23 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1:^y }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 ]], float_pos=expected_pos} else screen:expect([[ x | {0:~ }| {0:~ }{1:^y }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }|*3 | ]]) end @@ -6894,38 +5593,21 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {1:^y }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 ]], float_pos=expected_pos} else screen:expect([[ x {1:^y } | - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| - {0:~ }{2:~ }{0: }| + {0:~ }{2:~ }{0: }|*5 | ]]) end @@ -6936,20 +5618,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6962,8 +5635,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -6972,20 +5644,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -6998,8 +5661,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -7008,20 +5670,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -7034,8 +5687,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -7044,20 +5696,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -7070,8 +5713,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -7080,20 +5722,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -7106,8 +5739,7 @@ describe('float window', function() {0:~ }| {1:^y }| {2:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -7118,11 +5750,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7153,11 +5783,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7188,11 +5816,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7224,11 +5850,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7261,11 +5885,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7296,11 +5918,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7331,11 +5951,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7368,11 +5986,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7405,11 +6021,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7442,19 +6056,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| + [5:--------------------]{5:│}[2:-------------------]|*5 {4:[No Name] [+] }{5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -7462,10 +6069,7 @@ describe('float window', function() {2:~ }| ## grid 5 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} else screen:expect([[ @@ -7485,19 +6089,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| + [5:--------------------]{5:│}[2:-------------------]|*5 {4:[No Name] }{5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :vnew | ## grid 4 @@ -7505,10 +6102,7 @@ describe('float window', function() {2:~ }| ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} else screen:expect([[ @@ -7528,19 +6122,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| - [5:--------------------]{5:│}[2:-------------------]| + [5:--------------------]{5:│}[2:-------------------]|*5 {4:[No Name] }{5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :vnew | ## grid 4 @@ -7548,10 +6135,7 @@ describe('float window', function() {2:~ }| ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} else screen:expect([[ @@ -7592,24 +6176,15 @@ describe('float window', function() -- enter first float feed('<c-w><c-w>') -- enter second float - meths.open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) + api.nvim_open_win(0, true, {relative='editor', width=20, height=2, row=4, col=8}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -7619,8 +6194,8 @@ describe('float window', function() {1:^y }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true}, - [5] = {{id = 1002}, "NW", 1, 4, 8, true} + [4] = {1001, "NW", 1, 2, 5, true}, + [5] = {1002, "NW", 1, 4, 8, true} }} else screen:expect([[ @@ -7638,27 +6213,18 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :quit | ## grid 4 {1:^y }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true}, + [4] = {1001, "NW", 1, 2, 5, true}, }} else screen:expect([[ @@ -7666,8 +6232,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 :quit | ]]) end @@ -7676,31 +6241,18 @@ describe('float window', function() if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :quit | ]]) else screen:expect([[ ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 :quit | ]]) end @@ -7713,31 +6265,18 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ]]} else screen:expect([[ ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end @@ -7748,20 +6287,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [3:----------------------------------------]| - [3:----------------------------------------]| - [3:----------------------------------------]| + [2:----------------------------------------]|*4 + [3:----------------------------------------]|*3 ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {7:E5601: Cannot close window, only floatin}| {7:g window would remain} | @@ -7787,20 +6317,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -7813,8 +6334,7 @@ describe('float window', function() {0:~ }| {0:~ }{1:^y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end @@ -7825,11 +6345,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {4:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7860,31 +6378,18 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 3 | ## grid 5 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ]]} else screen:expect([[ ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end @@ -7895,11 +6400,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7930,13 +6433,10 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*2 {5:[No Name] [+] }| [2:----------------------------------------]| - [3:----------------------------------------]| - [3:----------------------------------------]| - [3:----------------------------------------]| + [3:----------------------------------------]|*3 ## grid 2 x | {0:~ }| @@ -7969,11 +6469,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -7998,23 +6496,16 @@ describe('float window', function() end if multigrid then - meths.win_set_config(0, {external=true, width=30, height=2}) + api.nvim_win_set_config(0, {external=true, width=30, height=2}) expected_pos = {[4]={external=true}} screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 {5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 @@ -8023,7 +6514,7 @@ describe('float window', function() ]], float_pos=expected_pos} else eq("UI doesn't support external windows", - pcall_err(meths.win_set_config, 0, {external=true, width=30, height=2})) + pcall_err(api.nvim_win_set_config, 0, {external=true, width=30, height=2})) return end @@ -8031,11 +6522,9 @@ describe('float window', function() if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8051,24 +6540,15 @@ describe('float window', function() end) it('J (float with border)', function() - meths.win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'}) + api.nvim_win_set_config(win, {relative='editor', width=20, height=2, row=2, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8093,11 +6573,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*2 {5:[No Name] [+] }| - [4:----------------------------------------]| - [4:----------------------------------------]| + [4:----------------------------------------]|*2 {4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8128,11 +6606,9 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [6:--------------------]{5:│}[5:-------------------]| - [6:--------------------]{5:│}[5:-------------------]| + [6:--------------------]{5:│}[5:-------------------]|*2 {5:[No Name] [+] [No Name] [+] }| - [7:--------------------]{5:│}[2:-------------------]| - [7:--------------------]{5:│}[2:-------------------]| + [7:--------------------]{5:│}[2:-------------------]|*2 {4:[No Name] [+] }{5:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8169,17 +6645,15 @@ describe('float window', function() for i = 1,5 do feed(i.."<c-w>w") feed_command("enew") - curbufmeths.set_lines(0,-1,true,{tostring(i)}) + api.nvim_buf_set_lines(0, 0,-1,true,{tostring(i)}) end if multigrid then screen:expect{grid=[[ ## grid 1 - [6:-------------------]{5:│}[5:--------------------]| - [6:-------------------]{5:│}[5:--------------------]| + [6:-------------------]{5:│}[5:--------------------]|*2 {5:[No Name] [+] [No Name] [+] }| - [7:-------------------]{5:│}[2:--------------------]| - [7:-------------------]{5:│}[2:--------------------]| + [7:-------------------]{5:│}[2:--------------------]|*2 {5:[No Name] [+] [No Name] [+] }| [3:----------------------------------------]| ## grid 2 @@ -8227,7 +6701,7 @@ describe('float window', function() for i = 1,5 do feed(i.."<c-w>w") feed('<c-w>'..k) - local nr = funcs.winnr() + local nr = fn.winnr() eq(v[i],nr, "when using <c-w>"..k.." from window "..i) end end @@ -8238,7 +6712,7 @@ describe('float window', function() if j ~= i then feed(j.."<c-w>w") feed('<c-w>p') - local nr = funcs.winnr() + local nr = fn.winnr() eq(i,nr, "when using <c-w>p to window "..i.." from window "..j) end end @@ -8253,19 +6727,11 @@ describe('float window', function() screen:expect{grid=[[ ## grid 1 {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 (hidden) x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :tabnew | ## grid 4 (hidden) @@ -8273,19 +6739,13 @@ describe('float window', function() {2:~ }| ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]]} else screen:expect([[ {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 :tabnew | ]]) end @@ -8295,18 +6755,11 @@ describe('float window', function() screen:expect{grid=[[ ## grid 1 {3: }{11:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :tabnext | ## grid 4 @@ -8314,10 +6767,7 @@ describe('float window', function() {2:~ }| ## grid 5 (hidden) | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} else screen:expect([[ @@ -8325,8 +6775,7 @@ describe('float window', function() ^x | {0:~ }{1:y }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 :tabnext | ]]) end @@ -8336,18 +6785,11 @@ describe('float window', function() screen:expect{grid=[[ ## grid 1 {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 (hidden) x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :tabnext | ## grid 4 (hidden) @@ -8355,19 +6797,13 @@ describe('float window', function() {2:~ }| ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]]} else screen:expect([[ {9: }{10:2}{9:+ [No Name] }{3: [No Name] }{5: }{9:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 :tabnext | ]]) end @@ -8376,42 +6812,29 @@ describe('float window', function() it(":tabnew and :tabnext (external)", function() if multigrid then -- also test external window wider than main screen - meths.win_set_config(win, {external=true, width=65, height=4}) + api.nvim_win_set_config(win, {external=true, width=65, height=4}) expected_pos = {[4]={external=true}} feed(":tabnew<cr>") screen:expect{grid=[[ ## grid 1 {9: + [No Name] }{3: }{11:2}{3:+ [No Name] }{5: }{9:X}| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 (hidden) x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :tabnew | ## grid 4 y | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} else eq("UI doesn't support external windows", - pcall_err(meths.win_set_config, 0, {external=true, width=65, height=4})) + pcall_err(api.nvim_win_set_config, 0, {external=true, width=65, height=4})) end feed(":tabnext<cr>") @@ -8419,31 +6842,19 @@ describe('float window', function() screen:expect{grid=[[ ## grid 1 {3: }{11:2}{3:+ [No Name] }{9: [No Name] }{5: }{9:X}| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 ^x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :tabnext | ## grid 4 y | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 (hidden) | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} end @@ -8452,57 +6863,36 @@ describe('float window', function() screen:expect{grid=[[ ## grid 1 {9: + [No Name] }{3: }{11:2}{3:+ [No Name] }{5: }{9:X}| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| - [5:----------------------------------------]| + [5:----------------------------------------]|*5 [3:----------------------------------------]| ## grid 2 (hidden) x | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 :tabnext | ## grid 4 y | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 ## grid 5 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ]], float_pos=expected_pos} end end) end) it("left drag changes visual selection in float window", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8510,29 +6900,20 @@ describe('float window', function() {1:bar }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; + [4] = {1001, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8540,29 +6921,20 @@ describe('float window', function() {1:bar }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; + [4] = {1001, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 1, 2) + api.nvim_input_mouse('left', 'drag', '', 4, 1, 2) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- VISUAL --} | ## grid 4 @@ -8570,10 +6942,10 @@ describe('float window', function() {27:ba}{1:^r }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 2, 5, true, 50}; + [4] = {1001, "NW", 1, 2, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8586,7 +6958,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 2, 5) + api.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect{grid=[[ | {0:~ }| @@ -8597,7 +6969,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 3, 7) + api.nvim_input_mouse('left', 'drag', '', 0, 3, 7) screen:expect{grid=[[ | {0:~ }| @@ -8611,26 +6983,17 @@ describe('float window', function() end) it("left drag changes visual selection in float window with border", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8640,29 +7003,20 @@ describe('float window', function() {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 1, 1) + api.nvim_input_mouse('left', 'press', '', 4, 1, 1) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8672,29 +7026,20 @@ describe('float window', function() {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 2, 3) + api.nvim_input_mouse('left', 'drag', '', 4, 2, 3) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- VISUAL --} | ## grid 4 @@ -8704,10 +7049,10 @@ describe('float window', function() {5:│}{1:baz }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8720,7 +7065,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 1, 6) + api.nvim_input_mouse('left', 'press', '', 0, 1, 6) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{1:^foo }{5:│}{0: }| @@ -8731,7 +7076,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 2, 8) + api.nvim_input_mouse('left', 'drag', '', 0, 2, 8) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{27:foo}{1: }{5:│}{0: }| @@ -8745,27 +7090,18 @@ describe('float window', function() end) it("left drag changes visual selection in float window with winbar", function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - local float_win = meths.open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) - meths.set_option_value('winbar', 'floaty bar', {win=float_win.id}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + local float_win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=4, row=1, col=5}) + api.nvim_set_option_value('winbar', 'floaty bar', {win=float_win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8774,29 +7110,20 @@ describe('float window', function() {1:bar }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; + [4] = {1001, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'press', '', 4, 1, 0) + api.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -8805,29 +7132,20 @@ describe('float window', function() {1:bar }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; + [4] = {1001, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} - meths.input_mouse('left', 'drag', '', 4, 2, 2) + api.nvim_input_mouse('left', 'drag', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 {3:-- VISUAL --} | ## grid 4 @@ -8836,10 +7154,10 @@ describe('float window', function() {27:ba}{1:^r }| {1:baz }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; + [4] = {1001, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -8852,7 +7170,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'press', '', 0, 2, 5) + api.nvim_input_mouse('left', 'press', '', 0, 2, 5) screen:expect{grid=[[ | {0:~ }{3:floaty bar }{0: }| @@ -8863,7 +7181,7 @@ describe('float window', function() | ]]} - meths.input_mouse('left', 'drag', '', 0, 3, 7) + api.nvim_input_mouse('left', 'drag', '', 0, 3, 7) screen:expect{grid=[[ | {0:~ }{3:floaty bar }{0: }| @@ -8877,116 +7195,89 @@ describe('float window', function() end) it('left drag changes visual selection if float window is turned into a split', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) - meths.open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'foo', 'bar', 'baz'}) + api.nvim_open_win(buf, true, {relative='editor', width=20, height=3, row=2, col=5}) command('wincmd L') if multigrid then screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]|*5 {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 ^foo | bar | baz | - {0:~ }| - {0:~ }| + {0:~ }|*2 ]]) - meths.input_mouse('left', 'press', '', 4, 2, 2) + api.nvim_input_mouse('left', 'press', '', 4, 2, 2) screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]|*5 {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 foo | bar | ba^z | - {0:~ }| - {0:~ }| + {0:~ }|*2 ]]) - meths.input_mouse('left', 'drag', '', 4, 1, 1) + api.nvim_input_mouse('left', 'drag', '', 4, 1, 1) screen:expect([[ ## grid 1 - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| - [2:-------------------]{5:│}[4:--------------------]| + [2:-------------------]{5:│}[4:--------------------]|*5 {5:[No Name] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 {3:-- VISUAL --} | ## grid 4 foo | b^a{27:r} | {27:baz} | - {0:~ }| - {0:~ }| + {0:~ }|*2 ]]) else screen:expect([[ {5:│}^foo | {0:~ }{5:│}bar | {0:~ }{5:│}baz | - {0:~ }{5:│}{0:~ }| - {0:~ }{5:│}{0:~ }| + {0:~ }{5:│}{0:~ }|*2 {5:[No Name] }{4:[No Name] [+] }| | ]]) - meths.input_mouse('left', 'press', '', 0, 2, 22) + api.nvim_input_mouse('left', 'press', '', 0, 2, 22) screen:expect([[ {5:│}foo | {0:~ }{5:│}bar | {0:~ }{5:│}ba^z | - {0:~ }{5:│}{0:~ }| - {0:~ }{5:│}{0:~ }| + {0:~ }{5:│}{0:~ }|*2 {5:[No Name] }{4:[No Name] [+] }| | ]]) - meths.input_mouse('left', 'drag', '', 0, 1, 21) + api.nvim_input_mouse('left', 'drag', '', 0, 1, 21) screen:expect([[ {5:│}foo | {0:~ }{5:│}b^a{27:r} | {0:~ }{5:│}{27:baz} | - {0:~ }{5:│}{0:~ }| - {0:~ }{5:│}{0:~ }| + {0:~ }{5:│}{0:~ }|*2 {5:[No Name] }{4:[No Name] [+] }| {3:-- VISUAL --} | ]]) @@ -8994,46 +7285,33 @@ describe('float window', function() end) it('left click sets correct curswant in float window with border', function() - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'', '', ''}) - meths.open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'', '', ''}) + api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=0, col=5, border='single'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*3 {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ {5:┌────────────────────┐} | - {0:~ }{5:│}{1: }{5:│}{0: }| - {0:~ }{5:│}{1: }{5:│}{0: }| - {0:~ }{5:│}{1: }{5:│}{0: }| + {0:~ }{5:│}{1: }{5:│}{0: }|*3 {0:~ }{5:└────────────────────┘}{0: }| {0:~ }| | @@ -9041,45 +7319,36 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 1) + api.nvim_input_mouse('left', 'press', '', 4, 3, 1) else - meths.input_mouse('left', 'press', '', 0, 3, 6) + api.nvim_input_mouse('left', 'press', '', 0, 3, 6) end - eq({0, 3, 1, 0, 1}, funcs.getcurpos()) + eq({0, 3, 1, 0, 1}, fn.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 2) + api.nvim_input_mouse('left', 'press', '', 4, 3, 2) else - meths.input_mouse('left', 'press', '', 0, 3, 7) + api.nvim_input_mouse('left', 'press', '', 0, 3, 7) end - eq({0, 3, 1, 0, 2}, funcs.getcurpos()) + eq({0, 3, 1, 0, 2}, fn.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 3, 10) + api.nvim_input_mouse('left', 'press', '', 4, 3, 10) else - meths.input_mouse('left', 'press', '', 0, 3, 15) + api.nvim_input_mouse('left', 'press', '', 0, 3, 15) end - eq({0, 3, 1, 0, 10}, funcs.getcurpos()) + eq({0, 3, 1, 0, 10}, fn.getcurpos()) command('setlocal foldcolumn=1') feed('zfkgg') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -9089,10 +7358,10 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 4, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 4, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9107,23 +7376,14 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 1) + api.nvim_input_mouse('left', 'press', '', 4, 2, 1) screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -9133,13 +7393,13 @@ describe('float window', function() {5:│}{19:│}{1: }{5:│}| {5:└────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 5, true, 50}; + [4] = {1001, "NW", 1, 0, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 3, sum_scroll_delta = 0}; }} else - meths.input_mouse('left', 'press', '', 0, 2, 6) + api.nvim_input_mouse('left', 'press', '', 0, 2, 6) screen:expect{grid=[[ {5:┌────────────────────┐} | {0:~ }{5:│}{19: }{1:^ }{5:│}{0: }| @@ -9152,25 +7412,25 @@ describe('float window', function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) + api.nvim_input_mouse('left', 'press', '', 4, 2, 2) else - meths.input_mouse('left', 'press', '', 0, 2, 7) + api.nvim_input_mouse('left', 'press', '', 0, 2, 7) end - eq({0, 2, 1, 0, 1}, funcs.getcurpos()) + eq({0, 2, 1, 0, 1}, fn.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 3) + api.nvim_input_mouse('left', 'press', '', 4, 2, 3) else - meths.input_mouse('left', 'press', '', 0, 2, 8) + api.nvim_input_mouse('left', 'press', '', 0, 2, 8) end - eq({0, 2, 1, 0, 2}, funcs.getcurpos()) + eq({0, 2, 1, 0, 2}, fn.getcurpos()) if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 11) + api.nvim_input_mouse('left', 'press', '', 4, 2, 11) else - meths.input_mouse('left', 'press', '', 0, 2, 16) + api.nvim_input_mouse('left', 'press', '', 0, 2, 16) end - eq({0, 2, 1, 0, 10}, funcs.getcurpos()) + eq({0, 2, 1, 0, 10}, fn.getcurpos()) end) it("'winblend' option", function() @@ -9188,8 +7448,8 @@ describe('float window', function() [10] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 0}, [11] = {foreground = Screen.colors.Red, background = Screen.colors.LightMagenta, blend = 80}, [12] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue1, blend = 30}, - [13] = {background = Screen.colors.LightGray, blend = 30}, - [14] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey88}, + [13] = {foreground = Screen.colors.Black, background = Screen.colors.LightGray, blend = 30}, + [14] = {foreground = Screen.colors.Black, background = Screen.colors.Grey88}, [15] = {foreground = tonumber('0x939393'), background = Screen.colors.Grey88}, [16] = {background = Screen.colors.Grey90}; [17] = {blend = 100}; @@ -9214,20 +7474,13 @@ describe('float window', function() occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.]]) - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"}) - local win = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {"test", "", "popup text"}) + local win = api.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=2, col=5}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9244,7 +7497,7 @@ describe('float window', function() {1:test }| {1: }| {1:popup text }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9259,18 +7512,11 @@ describe('float window', function() ]]) end - meths.set_option_value("winblend", 30, {win=win.id}) + api.nvim_set_option_value("winblend", 30, {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9287,7 +7533,7 @@ describe('float window', function() {9:test }| {9: }| {9:popup text }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}, unchanged=true} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9303,18 +7549,11 @@ describe('float window', function() end -- Check that 'winblend' works with NormalNC highlight - meths.set_option_value('winhighlight', 'NormalNC:Visual', {win = win}) + api.nvim_set_option_value('winhighlight', 'NormalNC:Visual', {win = win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9331,7 +7570,7 @@ describe('float window', function() {13:test }| {13: }| {13:popup text }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9355,18 +7594,11 @@ describe('float window', function() command('hi clear NormalNC') command('hi SpecialRegion guifg=Red blend=0') - meths.buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1) + api.nvim_buf_add_highlight(buf, -1, "SpecialRegion", 2, 0, -1) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9383,7 +7615,7 @@ describe('float window', function() {9:test }| {9: }| {10:popup text}{9: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9402,14 +7634,7 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9426,7 +7651,7 @@ describe('float window', function() {9:test }| {9: }| {11:popup text}{9: }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}, unchanged=true} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}, unchanged=true} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9443,17 +7668,10 @@ describe('float window', function() -- Test scrolling by mouse if multigrid then - meths.input_mouse('wheel', 'down', '', 4, 2, 2) + api.nvim_input_mouse('wheel', 'down', '', 4, 2, 2) screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9468,11 +7686,10 @@ describe('float window', function() | ## grid 4 {11:popup text}{9: }| - {12:~ }| - {12:~ }| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + {12:~ }|*2 + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}} else - meths.input_mouse('wheel', 'down', '', 0, 4, 7) + api.nvim_input_mouse('wheel', 'down', '', 0, 4, 7) screen:expect([[ Ut enim ad minim veniam, quis nostrud | exercitation ullamco laboris nisi ut aliquip ex | @@ -9487,22 +7704,15 @@ describe('float window', function() end -- Check that 'winblend' applies to border/title/footer - meths.win_set_config(win, {border='single', title='Title', footer='Footer'}) - meths.set_option_value('winblend', 100, {win=win.id}) - meths.set_option_value("cursorline", true, {win=0}) + api.nvim_win_set_config(win, {border='single', title='Title', footer='Footer'}) + api.nvim_set_option_value('winblend', 100, {win=win}) + api.nvim_set_option_value("cursorline", true, {win=0}) command('hi clear VertSplit') feed('k0') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| - [2:--------------------------------------------------]| + [2:--------------------------------------------------]|*8 [3:--------------------------------------------------]| ## grid 2 Ut enim ad minim veniam, quis nostrud | @@ -9518,10 +7728,9 @@ describe('float window', function() ## grid 4 {17:┌}{23:Title}{17:──────────┐}| {17:│}{11:popup text}{18: }{17:│}| - {17:│}{19:~ }{17:│}| - {17:│}{19:~ }{17:│}| + {17:│}{19:~ }{17:│}|*2 {17:└}{23:Footer}{17:─────────┘}| - ]], float_pos={[4] = {{id = 1001}, "NW", 1, 2, 5, true}}} + ]], float_pos={[4] = {1001, "NW", 1, 2, 5, true}}} else screen:expect([[ Ut enim ad minim veniam, quis nostrud | @@ -9541,63 +7750,44 @@ describe('float window', function() insert([[ # TODO: 测试字典信息的准确性 # FIXME: 测试字典信息的准确性]]) - local buf = meths.create_buf(false,false) - meths.buf_set_lines(buf, 0, -1, true, {'口', '口'}) - local win = meths.open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) + local buf = api.nvim_create_buf(false,false) + api.nvim_buf_set_lines(buf, 0, -1, true, {'口', '口'}) + local win = api.nvim_open_win(buf, false, {relative='editor', width=5, height=3, row=0, col=11, style='minimal'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 # TODO: 测试字典信息的准确性 | # FIXME: 测试字典信息的准确^性 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ## grid 4 - {1:口 }| - {1:口 }| + {1:口 }|*2 {1: }| - ]], float_pos={ [4] = { { id = 1001 }, "NW", 1, 0, 11, true } }} + ]], float_pos={ [4] = { 1001, "NW", 1, 0, 11, true } }} else screen:expect([[ # TODO: 测 {1:口 }信息的准确性 | # FIXME: 测{1:口 } 信息的准确^性 | {0:~ }{1: }{0: }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end - meths.win_close(win, false) + api.nvim_win_close(win, false) if multigrid then screen:expect([[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 # TODO: 测试字典信息的准确性 | # FIXME: 测试字典信息的准确^性 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 ## grid 3 | ]]) @@ -9605,10 +7795,7 @@ describe('float window', function() screen:expect([[ # TODO: 测试字典信息的准确性 | # FIXME: 测试字典信息的准确^性 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end @@ -9616,9 +7803,9 @@ describe('float window', function() -- The interaction between 'winblend' and doublewidth chars in the background -- does not look very good. But check no chars get incorrectly placed -- at least. Also check invisible EndOfBuffer region blends correctly. - meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) - win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) - meths.set_option_value('winblend', 30, {win=win.id}) + api.nvim_buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"}) + win = api.nvim_open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'}) + api.nvim_set_option_value('winblend', 30, {win=win}) screen:set_default_attr_ids({ [1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')}, [2] = {foreground = Screen.colors.Grey0, background = tonumber('0xffcfff')}, @@ -9629,20 +7816,12 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 # TODO: 测试字典信息的准确性 | # FIXME: 测试字典信息的准确^性 | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 ## grid 3 | ## grid 5 @@ -9650,38 +7829,28 @@ describe('float window', function() {5: x x x x}| {5: }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 11, true } + [5] = { 1002, "NW", 1, 0, 11, true } }} else screen:expect([[ # TODO: 测 {2: x x x}{1:息}{2: xx} 确性 | # FIXME: 测{1:试}{2:x x x}{1:息}{2: x}准确^性 | {3:~ }{4: }{3: }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 | ]]) end - meths.win_set_config(win, {relative='editor', row=0, col=12}) + api.nvim_win_set_config(win, {relative='editor', row=0, col=12}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 # TODO: 测试字典信息的准确性 | # FIXME: 测试字典信息的准确^性 | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 ## grid 3 | ## grid 5 @@ -9689,16 +7858,14 @@ describe('float window', function() {5: x x x x}| {5: }| ]], float_pos={ - [5] = { { id = 1002 }, "NW", 1, 0, 12, true } + [5] = { 1002, "NW", 1, 0, 12, true } }} else screen:expect([[ # TODO: 测试{2: x x}{1:信}{2:x }{1:的}{2:xx}确性 | # FIXME: 测 {2: x x}{1:信}{2:x }{1:的}{2:x} 确^性 | {3:~ }{4: }{3: }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 | ]]) end @@ -9735,20 +7902,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -9757,20 +7915,14 @@ describe('float window', function() {2:longest}| ## grid 5 {2:---------}| - {2:- -}| - {2:- -}| - {2: }| - {2: }| + {2:- -}|*2 + {2: }|*2 ]], attr_ids={ [1] = {foreground = Screen.colors.Blue1, bold = true}; [2] = {background = Screen.colors.LightMagenta}; }, float_pos={ - [4] = { { - id = 1001 - }, "NW", 1, 1, 1, true }, - [5] = { { - id = 1002 - }, "NW", 1, 0, 0, true } + [4] = { 1001, "NW", 1, 1, 1, true }, + [5] = { 1002, "NW", 1, 0, 0, true } }} else screen:expect([[ @@ -9803,20 +7955,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -9825,16 +7968,14 @@ describe('float window', function() {2:n}| ## grid 5 {2:---}| - {2:- -}| - {2:- -}| - {2: }| - {2: }| + {2:- -}|*2 + {2: }|*2 ]], attr_ids={ [1] = {foreground = Screen.colors.Blue1, bold = true}; [2] = {background = Screen.colors.LightMagenta}; }, float_pos={ - [4] = { { id = 1001 }, "NW", 1, 1, 1, true }, - [5] = { { id = 1002 }, "NW", 1, 0, 0, true } + [4] = { 1001, "NW", 1, 1, 1, true }, + [5] = { 1002, "NW", 1, 0, 0, true } }} else screen:expect([[ @@ -9850,37 +7991,28 @@ describe('float window', function() end) it("correctly orders multiple opened floats (current last)", function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7: }| {7:~ }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; + [4] = { 1001, "NW", 1, 2, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9888,8 +8020,7 @@ describe('float window', function() {0:~ }| {0:~ }{7: }{0: }| {0:~ }{7:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end @@ -9906,20 +8037,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -9932,14 +8054,14 @@ describe('float window', function() {17:^ }| {17:~ }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; - [5] = { { id = 1002 }, "NW", 1, 3, 8, true }; - [6] = { { id = 1003 }, "NW", 1, 4, 10, true }; + [4] = { 1001, "NW", 1, 2, 5, true }; + [5] = { 1002, "NW", 1, 3, 8, true }; + [6] = { 1003, "NW", 1, 4, 10, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; + [6] = {win = 1003, topline = 0, botline = 2, curline = 0, curcol = 0, linecount=1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9955,37 +8077,28 @@ describe('float window', function() end) it("correctly orders multiple opened floats (non-current last)", function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win.id}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=20, height=2, row=2, col=5}) + api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7: }| {7:~ }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; + [4] = { 1001, "NW", 1, 2, 5, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -9993,8 +8106,7 @@ describe('float window', function() {0:~ }| {0:~ }{7: }{0: }| {0:~ }{7:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end @@ -10011,20 +8123,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -10037,14 +8140,14 @@ describe('float window', function() {1: }| {1:~ }| ]], float_pos={ - [4] = { { id = 1001 }, "NW", 1, 2, 5, true }; - [5] = { { id = 1002 }, "NW", 1, 4, 10, true }; - [6] = { { id = 1003 }, "NW", 1, 3, 8, true }; + [4] = { 1001, "NW", 1, 2, 5, true }; + [5] = { 1002, "NW", 1, 4, 10, true }; + [6] = { 1003, "NW", 1, 3, 8, true }; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = 1003, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10060,54 +8163,42 @@ describe('float window', function() end) it('can use z-index', function() - local buf = meths.create_buf(false,false) - local win1 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30}) - meths.set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1.id}) - local win2 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50}) - meths.set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2.id}) - local win3 = meths.open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40}) - meths.set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3.id}) + local buf = api.nvim_create_buf(false,false) + local win1 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=1, col=5, zindex=30}) + api.nvim_set_option_value("winhl", "Normal:ErrorMsg,EndOfBuffer:ErrorMsg", {win=win1}) + local win2 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=2, col=6, zindex=50}) + api.nvim_set_option_value("winhl", "Normal:Search,EndOfBuffer:Search", {win=win2}) + local win3 = api.nvim_open_win(buf, false, {relative='editor', width=20, height=3, row=3, col=7, zindex=40}) + api.nvim_set_option_value("winhl", "Normal:Question,EndOfBuffer:Question", {win=win3}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {7: }| - {7:~ }| - {7:~ }| + {7:~ }|*2 ## grid 5 {17: }| - {17:~ }| - {17:~ }| + {17:~ }|*2 ## grid 6 {8: }| - {8:~ }| - {8:~ }| + {8:~ }|*2 ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 5, true, 30}; - [5] = {{id = 1002}, "NW", 1, 2, 6, true, 50}; - [6] = {{id = 1003}, "NW", 1, 3, 7, true, 40}; + [4] = {1001, "NW", 1, 1, 5, true, 30}; + [5] = {1002, "NW", 1, 2, 6, true, 50}; + [6] = {1003, "NW", 1, 3, 7, true, 40}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [6] = {win = {id = 1003}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [6] = {win = 1003, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10123,27 +8214,18 @@ describe('float window', function() end) it('can use winbar', function() - local buf = meths.create_buf(false,false) - local win1 = meths.open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) - meths.set_option_value('winbar', 'floaty bar', {win=win1.id}) + local buf = api.nvim_create_buf(false,false) + local win1 = api.nvim_open_win(buf, false, {relative='editor', width=15, height=3, row=1, col=5}) + api.nvim_set_option_value('winbar', 'floaty bar', {win=win1}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -10151,10 +8233,10 @@ describe('float window', function() {1: }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 5, true, 50}; + [4] = {1001, "NW", 1, 1, 5, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10162,54 +8244,42 @@ describe('float window', function() {0:~ }{3:floaty bar }{0: }| {0:~ }{1: }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]} end -- resize and add a border - meths.win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'}) + api.nvim_win_set_config(win1, {relative='editor', width=15, height=4, row=0, col=4, border = 'single'}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌───────────────┐}| {5:│}{3:floaty bar }{5:│}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*2 {5:└───────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 0, 4, true, 50}; + [4] = {1001, "NW", 1, 0, 4, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ {5:┌───────────────┐} | {0:~ }{5:│}{3:floaty bar }{5:│}{0: }| {0:~ }{5:│}{1: }{5:│}{0: }| - {0:~ }{5:│}{2:~ }{5:│}{0: }| - {0:~ }{5:│}{2:~ }{5:│}{0: }| + {0:~ }{5:│}{2:~ }{5:│}{0: }|*2 {0:~ }{5:└───────────────┘}{0: }| | ]]} @@ -10219,55 +8289,33 @@ describe('float window', function() it('it can be resized with messages and cmdheight=0 #20106', function() screen:try_resize(40,9) command 'set cmdheight=0' - local buf = meths.create_buf(false,true) - local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true}) + local buf = api.nvim_create_buf(false,true) + local win = api.nvim_open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=9, col=0, style='minimal', border="single", noautocmd=true}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 ## grid 4 {5:┌────────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*4 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "SW", 1, 9, 0, true, 50}; + [4] = {1001, "SW", 1, 9, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {5:┌──────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*4 {5:└──────────────────────────────────────┘}| ]]} end @@ -10281,144 +8329,83 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 ## grid 4 {5:┌────────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*2 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "SW", 1, 9, 0, true, 50}; + [4] = {1001, "SW", 1, 9, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {5:┌──────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*2 {5:└──────────────────────────────────────┘}| ]]} end - meths.win_close(win, true) + api.nvim_win_close(win, true) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*9 ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ## grid 3 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 ]]} end end) it('it can be resized with messages and cmdheight=1', function() screen:try_resize(40,9) - local buf = meths.create_buf(false,true) - local win = meths.open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true}) + local buf = api.nvim_create_buf(false,true) + local win = api.nvim_open_win(buf, false, {relative='editor', width=40, height=4, anchor='SW', row=8, col=0, style='minimal', border="single", noautocmd=true}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*8 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 | ## grid 4 {5:┌────────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*4 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; + [4] = {1001, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | {0:~ }| {5:┌──────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*4 {5:└──────────────────────────────────────┘}| | ]]} @@ -10436,48 +8423,30 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [3:----------------------------------------]| - [3:----------------------------------------]| + [2:----------------------------------------]|*7 + [3:----------------------------------------]|*2 ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 | {8:Press ENTER or type command to continue}^ | ## grid 4 {5:┌────────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*4 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; + [4] = {1001, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ | {0:~ }| {5:┌──────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*3 {4: }| | {8:Press ENTER or type command to continue}^ | @@ -10488,88 +8457,52 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*8 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 | ## grid 4 {5:┌────────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*2 {5:└────────────────────────────────────────┘}| ]], float_pos={ - [4] = {{id = 1001}, "SW", 1, 8, 0, true, 50}; + [4] = {1001, "SW", 1, 8, 0, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {5:┌──────────────────────────────────────┐}| - {5:│}{1: }{5:│}| - {5:│}{1: }{5:│}| + {5:│}{1: }{5:│}|*2 {5:└──────────────────────────────────────┘}| | ]]} end - meths.win_close(win, true) + api.nvim_win_close(win, true) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*8 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 | ]]} end @@ -10578,9 +8511,9 @@ describe('float window', function() describe('no crash after moving and closing float window #21547', function() local function test_float_move_close(cmd) local float_opts = {relative = 'editor', row = 1, col = 1, width = 10, height = 10} - meths.open_win(meths.create_buf(false, false), true, float_opts) + api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts) if multigrid then - screen:expect({float_pos = {[4] = {{id = 1001}, 'NW', 1, 1, 1, true}}}) + screen:expect({float_pos = {[4] = {1001, 'NW', 1, 1, 1, true}}}) end command(cmd) exec_lua([[ @@ -10605,26 +8538,17 @@ describe('float window', function() it(':sleep cursor placement #22639', function() local float_opts = {relative = 'editor', row = 1, col = 1, width = 4, height = 3} - local win = meths.open_win(meths.create_buf(false, false), true, float_opts) + local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts) feed('iab<CR>cd<Esc>') feed(':sleep 100') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100^ | ## grid 4 @@ -10632,10 +8556,10 @@ describe('float window', function() {1:cd }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10643,8 +8567,7 @@ describe('float window', function() {0:~}{1:ab }{0: }| {0:~}{1:cd }{0: }| {0:~}{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 :sleep 100^ | ]]} end @@ -10653,20 +8576,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100 | ## grid 4 @@ -10674,10 +8588,10 @@ describe('float window', function() {1:c^d }| {2:~ }| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10685,33 +8599,23 @@ describe('float window', function() {0:~}{1:ab }{0: }| {0:~}{1:c^d }{0: }| {0:~}{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 :sleep 100 | ]]} end feed('<C-C>') screen:expect_unchanged() - meths.win_set_config(win, {border = 'single'}) + api.nvim_win_set_config(win, {border = 'single'}) feed(':sleep 100') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100^ | ## grid 4 @@ -10721,10 +8625,10 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:└────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10742,20 +8646,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100 | ## grid 4 @@ -10765,10 +8660,10 @@ describe('float window', function() {5:│}{2:~ }{5:│}| {5:└────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10789,20 +8684,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100^ | ## grid 4 @@ -10812,10 +8698,10 @@ describe('float window', function() {5:│}{1:cd }{5:│}| {5:└────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10833,20 +8719,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 :sleep 100 | ## grid 4 @@ -10856,10 +8733,10 @@ describe('float window', function() {5:│}{1:c^d }{5:│}| {5:└────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 1, curcol = 1, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10878,26 +8755,17 @@ describe('float window', function() it('with rightleft and border #22640', function() local float_opts = {relative='editor', width=5, height=3, row=1, col=1, border='single'} - meths.open_win(meths.create_buf(false, false), true, float_opts) + api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts) command('setlocal rightleft') feed('iabc<CR>def<Esc>') if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 @@ -10907,10 +8775,10 @@ describe('float window', function() {5:│}{2: ~}{5:│}| {5:└─────┘}| ]], float_pos={ - [4] = {{id = 1001}, "NW", 1, 1, 1, true, 50}; + [4] = {1001, "NW", 1, 1, 1, true, 50}; }, win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 3, curline = 1, curcol = 2, linecount = 2, sum_scroll_delta = 0}; }} else screen:expect{grid=[[ @@ -10926,29 +8794,20 @@ describe('float window', function() end) it('float window with hide option', function() - local buf = meths.create_buf(false,false) - local win = meths.open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true}) + local buf = api.nvim_create_buf(false,false) + local win = api.nvim_open_win(buf, false, {relative='editor', width=10, height=2, row=2, col=5, hide = true}) local expected_pos = { - [4]={{id=1001}, 'NW', 1, 2, 5, true}, + [4]={1001, 'NW', 1, 2, 5, true}, } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | @@ -10959,33 +8818,20 @@ describe('float window', function() else screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end - meths.win_set_config(win, {hide = false}) + api.nvim_win_set_config(win, {hide = false}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | @@ -10999,30 +8845,20 @@ describe('float window', function() {0:~ }| {0:~ }{1: }{0: }| {0:~ }{2:~ }{0: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end - meths.win_set_config(win, {hide=true}) + api.nvim_win_set_config(win, {hide=true}) if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | @@ -11033,85 +8869,55 @@ describe('float window', function() else screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end end) it(':fclose command #9663', function() - local buf_a = meths.create_buf(false,false) - local buf_b = meths.create_buf(false,false) - local buf_c = meths.create_buf(false,false) - local buf_d = meths.create_buf(false,false) + local buf_a = api.nvim_create_buf(false,false) + local buf_b = api.nvim_create_buf(false,false) + local buf_c = api.nvim_create_buf(false,false) + local buf_d = api.nvim_create_buf(false,false) local config_a = {relative='editor', width=11, height=11, row=5, col=5, border ='single', zindex=50} local config_b = {relative='editor', width=8, height=8, row=7, col=7, border ='single', zindex=70} local config_c = {relative='editor', width=4, height=4, row=9, col=9, border ='single',zindex=90} local config_d = {relative='editor', width=2, height=2, row=10, col=10, border ='single',zindex=100} - meths.open_win(buf_a, false, config_a) - meths.open_win(buf_b, false, config_b) - meths.open_win(buf_c, false, config_c) - meths.open_win(buf_d, false, config_d) + api.nvim_open_win(buf_a, false, config_a) + api.nvim_open_win(buf_b, false, config_b) + api.nvim_open_win(buf_c, false, config_c) + api.nvim_open_win(buf_d, false, config_d) local expected_pos = { - [4]={{id=1001}, 'NW', 1, 5, 5, true, 50}, - [5]={{id=1002}, 'NW', 1, 7, 7, true, 70}, - [6]={{id=1003}, 'NW', 1, 9, 9, true, 90}, - [7]={{id=1004}, 'NW', 1, 10, 10, true, 100}, + [4]={1001, 'NW', 1, 5, 5, true, 50}, + [5]={1002, 'NW', 1, 7, 7, true, 70}, + [6]={1003, 'NW', 1, 9, 9, true, 90}, + [7]={1004, 'NW', 1, 10, 10, true, 100}, } if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌───────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*10 {5:└───────────┘}| ## grid 5 {5:┌────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*7 {5:└────────┘}| ## grid 6 {5:┌────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*3 {5:└────┘}| ## grid 7 {5:┌──┐}| @@ -11136,63 +8942,35 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌───────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*10 {5:└───────────┘}| ## grid 5 {5:┌────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*7 {5:└────────┘}| ## grid 6 {5:┌────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*3 {5:└────┘}| ]], float_pos=expected_pos} else screen:expect([[ ^ {5:┌─┌─┌────┐─┐┐} | {0:~ }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:│}{1: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~}{5:│}{2:~ }{5:│}{2: }{5:││}{0: }|*3 {0:~ }{5:│}{2:~}{5:│}{2:~}{5:└────┘}{2: }{5:││}{0: }| | ]]) @@ -11203,57 +8981,30 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | ## grid 4 {5:┌───────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*10 {5:└───────────┘}| ## grid 5 {5:┌────────┐}| {5:│}{1: }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| - {5:│}{2:~ }{5:│}| + {5:│}{2:~ }{5:│}|*7 {5:└────────┘}| ]], float_pos=expected_pos} else screen:expect([[ ^ {5:┌─┌────────┐┐} | {0:~ }{5:│}{1: }{5:│}{1: }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| - {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }| + {0:~ }{5:│}{2:~}{5:│}{2:~ }{5:││}{0: }|*4 | ]]) end @@ -11262,20 +9013,11 @@ describe('float window', function() if multigrid then screen:expect{grid=[[ ## grid 1 - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| - [2:----------------------------------------]| + [2:----------------------------------------]|*6 [3:----------------------------------------]| ## grid 2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 ## grid 3 | @@ -11283,15 +9025,82 @@ describe('float window', function() else screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end end) + + it('correctly placed in or above message area', function() + local float_opts = {relative='editor', width=5, height=1, row=100, col=1, border = 'single'} + api.nvim_set_option_value('cmdheight', 3, {}) + command("echo 'cmdline'") + local win = api.nvim_open_win(api.nvim_create_buf(false, false), true, float_opts) + -- Not hidden behind message area but placed above it. + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]|*4 + [3:----------------------------------------]|*3 + ## grid 2 + | + {0:~ }|*3 + ## grid 3 + cmdline | + |*2 + ## grid 4 + {5:┌─────┐}| + {5:│}{1:^ }{5:│}| + {5:└─────┘}| + ]], float_pos={ + [4] = {1001, "NW", 1, 100, 1, true, 50}; + }, win_viewport={ + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + | + {0:~}{5:┌─────┐}{0: }| + {0:~}{5:│}{1:^ }{5:│}{0: }| + {0:~}{5:└─────┘}{0: }| + cmdline | + |*2 + ]]} + end + -- Not placed above message area and visible on top of it. + api.nvim_win_set_config(win, {zindex = 300}) + if multigrid then + screen:expect{grid=[[ + ## grid 1 + [2:----------------------------------------]|*4 + [3:----------------------------------------]|*3 + ## grid 2 + | + {0:~ }|*3 + ## grid 3 + cmdline | + |*2 + ## grid 4 + {5:┌─────┐}| + {5:│}{1:^ }{5:│}| + {5:└─────┘}| + ]], float_pos={ + [4] = {1001, "NW", 1, 100, 1, true, 300}; + }, win_viewport={ + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 1, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + }} + else + screen:expect{grid=[[ + | + {0:~ }|*3 + c{5:┌─────┐} | + {5:│}{1:^ }{5:│} | + {5:└─────┘} | + ]]} + end + end) end describe('with ext_multigrid', function() diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 1addf7088e..7f13b6bd03 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -4,12 +4,11 @@ local clear, feed, eq = helpers.clear, helpers.feed, helpers.eq local command = helpers.command local feed_command = helpers.feed_command local insert = helpers.insert -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local exec = helpers.exec local assert_alive = helpers.assert_alive - local content1 = [[ This is a valid English @@ -18,7 +17,7 @@ local content1 = [[ in his cave. ]] -describe("folded lines", function() +describe('folded lines', function() before_each(function() clear() command('hi VertSplit gui=reverse') @@ -28,280 +27,338 @@ describe("folded lines", function() local screen before_each(function() screen = Screen.new(45, 8) - screen:attach({rgb=true, ext_multigrid=multigrid}) + screen:attach({ rgb = true, ext_multigrid = multigrid }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {reverse = true}, - [3] = {bold = true, reverse = true}, - [4] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - [5] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, - [6] = {background = Screen.colors.Yellow}, - [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [8] = {foreground = Screen.colors.Brown }, - [9] = {bold = true, foreground = Screen.colors.Brown}, - [10] = {background = Screen.colors.LightGrey, underline = true}, - [11] = {bold = true}, - [12] = {foreground = Screen.colors.Red}, - [13] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, - [14] = {background = Screen.colors.Red}, - [15] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Red}, - [16] = {background = Screen.colors.LightGrey}, - [17] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red}, - [18] = {background = Screen.colors.LightGrey, bold = true, foreground = Screen.colors.Blue}, - [19] = {background = Screen.colors.Yellow, foreground = Screen.colors.DarkBlue}, - [20] = {background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { reverse = true }, + [3] = { bold = true, reverse = true }, + [4] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + [5] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, + [6] = { background = Screen.colors.Yellow }, + [7] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [8] = { foreground = Screen.colors.Brown }, + [9] = { bold = true, foreground = Screen.colors.Brown }, + [10] = { background = Screen.colors.LightGrey, underline = true }, + [11] = { bold = true }, + [12] = { foreground = Screen.colors.Red }, + [13] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey }, + [14] = { background = Screen.colors.Red }, + [15] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Red }, + [16] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [17] = { background = Screen.colors.Yellow, foreground = Screen.colors.Red }, + [18] = { + background = Screen.colors.LightGrey, + bold = true, + foreground = Screen.colors.Blue, + }, + [19] = { background = Screen.colors.Yellow, foreground = Screen.colors.DarkBlue }, + [20] = { background = Screen.colors.Red, bold = true, foreground = Screen.colors.Blue }, }) end) - it("work with more than one signcolumn", function() - command("set signcolumn=yes:9") - feed("i<cr><esc>") - feed("vkzf") + it('with more than one signcolumn', function() + command('set signcolumn=yes:9') + feed('i<cr><esc>') + feed('vkzf') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7: }{5:^+-- 2 lines: ·············}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | ]]) else screen:expect([[ {7: }{5:^+-- 2 lines: ·············}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end end) - local function test_folded_cursorline() - command("set number cursorline foldcolumn=2") - command("hi link CursorLineFold Search") - insert(content1) - feed("ggzf3jj") - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| - {6: }{9: 5 }{12:^in his cave. }| - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - | - ]]) - else - screen:expect([[ - {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| - {6: }{9: 5 }{12:^in his cave. }| - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) + local function test_folded_cursorline(foldtext) + if not foldtext then + command('set foldtext=') end - feed("k") - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| - {7: }{8: 5 }in his cave. | - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - | - ]]) - else - screen:expect([[ - {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| - {7: }{8: 5 }in his cave. | - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) + command('set number cursorline foldcolumn=2') + command('hi link CursorLineFold Search') + insert(content1) + feed('ggzf3jj') + + if multigrid then + if foldtext then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + else + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {7:+ }{8: 1 }{5:This is a······························}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + end + else + if foldtext then + screen:expect([[ + {7:+ }{8: 1 }{5:+-- 4 lines: This is a················}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + else + screen:expect([[ + {7:+ }{8: 1 }{5:This is a······························}| + {6: }{9: 5 }{12:^in his cave. }| + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + end + end + + feed('k') + + if multigrid then + if foldtext then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + else + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {6:+ }{9: 1 }{13:^This is a······························}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + end + else + if foldtext then + screen:expect([[ + {6:+ }{9: 1 }{13:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + else + screen:expect([[ + {6:+ }{9: 1 }{13:^This is a······························}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + end end + -- CursorLine is applied correctly with screenrow motions #22232 - feed("jgk") + feed('jgk') screen:expect_unchanged() -- CursorLine is applied correctly when closing a fold when cursor is not at fold start - feed("zo4Gzc") + feed('zo4Gzc') screen:expect_unchanged() - command("set cursorlineopt=line") - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| - {7: }{8: 5 }in his cave. | - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - | - ]]) - else - screen:expect([[ - {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| - {7: }{8: 5 }in his cave. | - {7: }{8: 6 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) - end - command("set relativenumber cursorlineopt=number") - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| - {7: }{8: 1 }in his cave. | - {7: }{8: 2 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ## grid 3 - | - ]]) - else - screen:expect([[ - {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| - {7: }{8: 1 }in his cave. | - {7: }{8: 2 } | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - | - ]]) + command('set cursorlineopt=line') + + if multigrid then + if foldtext then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + else + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {7:+ }{8: 1 }{13:^This is a······························}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + end + else + if foldtext then + screen:expect([[ + {7:+ }{8: 1 }{13:^+-- 4 lines: This is a················}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + else + screen:expect([[ + {7:+ }{8: 1 }{13:^This is a······························}| + {7: }{8: 5 }in his cave. | + {7: }{8: 6 } | + {1:~ }|*4 + | + ]]) + end + end + + command('set relativenumber cursorlineopt=number') + + if multigrid then + if foldtext then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + else + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]|*7 + [3:---------------------------------------------]| + ## grid 2 + {6:+ }{9:1 }{5:^This is a······························}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }|*4 + ## grid 3 + | + ]]) + end + else + if foldtext then + screen:expect([[ + {6:+ }{9:1 }{5:^+-- 4 lines: This is a················}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }|*4 + | + ]]) + else + screen:expect([[ + {6:+ }{9:1 }{5:^This is a······························}| + {7: }{8: 1 }in his cave. | + {7: }{8: 2 } | + {1:~ }|*4 + | + ]]) + end end end describe("when 'cursorline' is set", function() - it('with high-priority CursorLine', function() - command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") - test_folded_cursorline() - end) - - it('with low-priority CursorLine', function() - command("hi! CursorLine guibg=NONE guifg=NONE gui=underline") - local attrs = screen:get_default_attr_ids() - attrs[12] = {underline = true} - attrs[13] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey, underline = true} - screen:set_default_attr_ids(attrs) - test_folded_cursorline() - end) + local function cursorline_tests(foldtext) + local sfx = not foldtext and ' (transparent foldtext)' or '' + it('with high-priority CursorLine' .. sfx, function() + command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') + test_folded_cursorline(foldtext) + end) + + it('with low-priority CursorLine' .. sfx, function() + command('hi! CursorLine guibg=NONE guifg=NONE gui=underline') + local attrs = screen:get_default_attr_ids() + attrs[12] = { underline = true } + attrs[13] = { + foreground = Screen.colors.DarkBlue, + background = Screen.colors.LightGrey, + underline = true, + } + screen:set_default_attr_ids(attrs) + test_folded_cursorline(foldtext) + end) + end + + cursorline_tests(true) + cursorline_tests(false) end) - it("work with spell", function() - command("set spell") + it('with spell', function() + command('set spell') insert(content1) - feed("gg") - feed("zf3j") + feed('gg') + feed('zf3j') if not multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ {5:^+-- 4 lines: This is a······················}| in his cave. | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } end end) - it("work with matches", function() + it('with matches', function() insert(content1) - command("highlight MyWord gui=bold guibg=red guifg=white") + command('highlight MyWord gui=bold guibg=red guifg=white') command("call matchadd('MyWord', '\\V' . 'test', -1)") - feed("gg") - feed("zf3j") + feed('gg') + feed('zf3j') if not multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ {5:^+-- 4 lines: This is a······················}| in his cave. | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } end end) - it("works with multibyte fillchars", function() + it('with multibyte fillchars', function() insert([[ aa bb @@ -309,22 +366,16 @@ describe("folded lines", function() dd ee ff]]) - command("set fillchars+=foldopen:▾,foldsep:│,foldclose:▸") + command('set fillchars+=foldopen:▾,foldsep:│,foldclose:▸') feed_command('1') - command("set foldcolumn=2") + command('set foldcolumn=2') feed('zf4j') feed('zf2j') feed('zO') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:▾▾}^aa | @@ -350,17 +401,11 @@ describe("folded lines", function() ]]) end - feed_command("set rightleft") + feed_command('set rightleft') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 a^a{7:▾▾}| @@ -386,77 +431,47 @@ describe("folded lines", function() ]]) end - feed_command("set norightleft") + feed_command('set norightleft') if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 1) + api.nvim_input_mouse('left', 'press', '', 2, 0, 1) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:▾▸}{5:^+--- 5 lines: aa··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 1) + api.nvim_input_mouse('left', 'press', '', 0, 0, 1) screen:expect([[ {7:▾▸}{5:^+--- 5 lines: aa··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :set norightleft | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:▸ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:▸ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 :set norightleft | ]]) end @@ -464,53 +479,35 @@ describe("folded lines", function() -- Add a winbar to avoid double-clicks command('setlocal winbar=!!!!!!') if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + api.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {11:!!!!!! }| {7:▾▸}{5:^+--- 5 lines: aa··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + api.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {11:!!!!!! }| {7:▾▸}{5:^+--- 5 lines: aa··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :set norightleft | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 1) + api.nvim_input_mouse('left', 'press', '', 2, 1, 1) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {11:!!!!!! }| @@ -524,7 +521,7 @@ describe("folded lines", function() :set norightleft | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 1) + api.nvim_input_mouse('left', 'press', '', 0, 1, 1) screen:expect([[ {11:!!!!!! }| {7:▾▾}^aa | @@ -538,7 +535,7 @@ describe("folded lines", function() end end) - it("works with split", function() + it('with split', function() insert([[ aa bb @@ -547,12 +544,12 @@ describe("folded lines", function() ee ff]]) feed_command('2') - command("set foldcolumn=1") + command('set foldcolumn=1') feed('zf3j') feed_command('1') feed('zf2j') feed('zO') - feed_command("rightbelow new") + feed_command('rightbelow new') insert([[ aa bb @@ -561,20 +558,17 @@ describe("folded lines", function() ee ff]]) feed_command('2') - command("set foldcolumn=1") + command('set foldcolumn=1') feed('zf3j') feed_command('1') feed('zf2j') if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*2 {2:[No Name] [+] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*3 {3:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -588,7 +582,7 @@ describe("folded lines", function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 3, 0) + api.nvim_input_mouse('left', 'press', '', 0, 3, 0) screen:expect([[ {7:-}aa | {7:-}bb | @@ -602,15 +596,12 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 0) + api.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*2 {2:[No Name] [+] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*3 {3:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -624,7 +615,7 @@ describe("folded lines", function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 4, 0) + api.nvim_input_mouse('left', 'press', '', 0, 4, 0) screen:expect([[ {7:-}aa | {7:-}bb | @@ -638,15 +629,12 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + api.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*2 {3:[No Name] [+] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*3 {2:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -660,7 +648,7 @@ describe("folded lines", function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + api.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {7:-}aa | {7:+}{5:^+--- 4 lines: bb···························}| @@ -674,15 +662,12 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*2 {3:[No Name] [+] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*3 {2:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -696,7 +681,7 @@ describe("folded lines", function() {7:2}cc | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:+}{5:^+-- 6 lines: aa····························}| {1:~ }| @@ -710,7 +695,7 @@ describe("folded lines", function() end end) - it("works with vsplit", function() + it('with vsplit', function() insert([[ aa bb @@ -719,12 +704,12 @@ describe("folded lines", function() ee ff]]) feed_command('2') - command("set foldcolumn=1") + command('set foldcolumn=1') feed('zf3j') feed_command('1') feed('zf2j') feed('zO') - feed_command("rightbelow vnew") + feed_command('rightbelow vnew') insert([[ aa bb @@ -733,20 +718,15 @@ describe("folded lines", function() ee ff]]) feed_command('2') - command("set foldcolumn=1") + command('set foldcolumn=1') feed('zf3j') feed_command('1') feed('zf2j') if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| + [2:----------------------]{2:│}[4:----------------------]|*6 {2:[No Name] [+] }{3:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -762,12 +742,10 @@ describe("folded lines", function() {7:-}^aa | {7:+}{5:+--- 4 lines: bb····}| {7:│}ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 23) + api.nvim_input_mouse('left', 'press', '', 0, 0, 23) screen:expect([[ {7:-}aa {2:│}{7:-}^aa | {7:-}bb {2:│}{7:+}{5:+--- 4 lines: bb····}| @@ -781,15 +759,10 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 0) + api.nvim_input_mouse('left', 'press', '', 4, 1, 0) screen:expect([[ ## grid 1 - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| + [2:----------------------]{2:│}[4:----------------------]|*6 {2:[No Name] [+] }{3:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 @@ -810,7 +783,7 @@ describe("folded lines", function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 23) + api.nvim_input_mouse('left', 'press', '', 0, 1, 23) screen:expect([[ {7:-}aa {2:│}{7:-}^aa | {7:-}bb {2:│}{7:-}bb | @@ -824,24 +797,17 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 0) + api.nvim_input_mouse('left', 'press', '', 2, 1, 0) screen:expect([[ ## grid 1 - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| + [2:----------------------]{2:│}[4:----------------------]|*6 {3:[No Name] [+] }{2:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 {7:-}aa | {7:+}{5:^+--- 4 lines: bb····}| {7:│}ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 :1 | ## grid 4 @@ -853,7 +819,7 @@ describe("folded lines", function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + api.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {7:-}aa {2:│}{7:-}aa | {7:+}{5:^+--- 4 lines: bb····}{2:│}{7:-}bb | @@ -867,24 +833,15 @@ describe("folded lines", function() end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| - [2:----------------------]{2:│}[4:----------------------]| + [2:----------------------]{2:│}[4:----------------------]|*6 {3:[No Name] [+] }{2:[No Name] [+] }| [3:---------------------------------------------]| ## grid 2 {7:+}{5:^+-- 6 lines: aa·····}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 :1 | ## grid 4 @@ -896,7 +853,7 @@ describe("folded lines", function() {7:│}ff | ]]) else - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {7:+}{5:^+-- 6 lines: aa·····}{2:│}{7:-}aa | {1:~ }{2:│}{7:-}bb | @@ -910,7 +867,7 @@ describe("folded lines", function() end end) - it("works with tab", function() + it('with tabpages', function() insert([[ aa bb @@ -919,23 +876,18 @@ describe("folded lines", function() ee ff]]) feed_command('2') - command("set foldcolumn=2") + command('set foldcolumn=2') feed('zf3j') feed_command('1') feed('zf2j') feed('zO') - feed_command("tab split") + feed_command('tab split') if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 1) + api.nvim_input_mouse('left', 'press', '', 4, 1, 1) screen:expect([[ ## grid 1 {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*6 [3:---------------------------------------------]| ## grid 2 (hidden) {7:- }aa | @@ -951,35 +903,26 @@ describe("folded lines", function() {7:- }^aa | {7:│+}{5:+--- 4 lines: bb··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]) else - meths.input_mouse('left', 'press', '', 0, 2, 1) + api.nvim_input_mouse('left', 'press', '', 0, 2, 1) screen:expect([[ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| {7:- }^aa | {7:│+}{5:+--- 4 lines: bb··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :tab split | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 0) + api.nvim_input_mouse('left', 'press', '', 4, 0, 0) screen:expect([[ ## grid 1 {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*6 [3:---------------------------------------------]| ## grid 2 (hidden) {7:- }aa | @@ -993,138 +936,90 @@ describe("folded lines", function() :tab split | ## grid 4 {7:+ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + api.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {10: + [No Name] }{11: + [No Name] }{2: }{10:X}| {7:+ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :tab split | ]]) end - feed_command("tabnext") + feed_command('tabnext') if multigrid then - meths.input_mouse('left', 'press', '', 2, 1, 1) + api.nvim_input_mouse('left', 'press', '', 2, 1, 1) screen:expect([[ ## grid 1 {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*6 [3:---------------------------------------------]| ## grid 2 {7:- }^aa | {7:│+}{5:+--- 4 lines: bb··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 :tabnext | ## grid 4 (hidden) {7:+ }{5:+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 2, 1) + api.nvim_input_mouse('left', 'press', '', 0, 2, 1) screen:expect([[ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| {7:- }^aa | {7:│+}{5:+--- 4 lines: bb··························}| {7:│ }ff | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :tabnext | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 2, 0, 0) + api.nvim_input_mouse('left', 'press', '', 2, 0, 0) screen:expect([[ ## grid 1 {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*6 [3:---------------------------------------------]| ## grid 2 {7:+ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 :tabnext | ## grid 4 (hidden) {7:+ }{5:+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]) else - meths.input_mouse('left', 'press', '', 0, 1, 0) + api.nvim_input_mouse('left', 'press', '', 0, 1, 0) screen:expect([[ {11: + [No Name] }{10: + [No Name] }{2: }{10:X}| {7:+ }{5:^+-- 6 lines: aa···························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :tabnext | ]]) end end) - it("works with multibyte text", function() - eq(true, meths.get_option_value('arabicshape', {})) + it('with multibyte text', function() + eq(true, api.nvim_get_option_value('arabicshape', {})) insert([[ å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢͟ العَرَبِيَّة möre text]]) if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | möre tex^t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ]]) @@ -1132,11 +1027,7 @@ describe("folded lines", function() screen:expect([[ å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ | möre tex^t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) end @@ -1145,215 +1036,119 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | ]]) else screen:expect([[ {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ ﺎﻠﻋَﺮَﺒِﻳَّﺓ·················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end - feed_command("set noarabicshape") + feed_command('set noarabicshape') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 :set noarabicshape | ]]) else screen:expect([[ {5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة·················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 :set noarabicshape | ]]) end - feed_command("set number foldcolumn=2") + feed_command('set number foldcolumn=2') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 :set number foldcolumn=2 | ]]) else screen:expect([[ {7:+ }{8: 1 }{5:^+-- 2 lines: å 语 x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ العَرَبِيَّة···········}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 :set number foldcolumn=2 | ]]) end -- Note: too much of the folded line gets cut off.This is a vim bug. - feed_command("set rightleft") + feed_command('set rightleft') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 ## grid 3 :set rightleft | ]]) else screen:expect([[ {5:···········ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}{8: 1 }{7: +}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 :set rightleft | ]]) end - feed_command("set nonumber foldcolumn=0") + feed_command('set nonumber foldcolumn=0') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 ## grid 3 :set nonumber foldcolumn=0 | ]]) else screen:expect([[ {5:·················ةيَّبِرَعَلا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 :set nonumber foldcolumn=0 | ]]) end - feed_command("set arabicshape") + feed_command('set arabicshape') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 ## grid 3 :set arabicshape | ]]) else screen:expect([[ {5:·················ﺔﻴَّﺑِﺮَﻌَﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å :senil 2 --^+}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*6 :set arabicshape | ]]) end @@ -1362,22 +1157,12 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*5 ## grid 3 :set arabicshape | ]]) @@ -1385,11 +1170,7 @@ describe("folded lines", function() screen:expect([[ ﺔﻴَّﺑِﺮَﻌَ^ﻟﺍ x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*5 :set arabicshape | ]]) end @@ -1398,22 +1179,12 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*5 ## grid 3 :set noarabicshape | ]]) @@ -1421,229 +1192,179 @@ describe("folded lines", function() screen:expect([[ ةيَّبِرَعَ^لا x̨̣̘̫̲͚͎̎͂̀̂͛͛̾͢ 语 å| txet eröm| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*5 :set noarabicshape | ]]) end - end) - it("work in cmdline window", function() - feed_command("set foldmethod=manual") - feed_command("let x = 1") - feed_command("/alpha") - feed_command("/omega") + it('in cmdline window', function() + feed_command('set foldmethod=manual foldcolumn=1') + feed_command('let x = 1') + feed_command('/alpha') + feed_command('/omega') - feed("<cr>q:") + feed('<cr>q:') if multigrid then screen:expect([[ ## grid 1 [2:---------------------------------------------]| {2:[No Name] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*4 {3:[Command Line] }| [3:---------------------------------------------]| ## grid 2 - | + {7: } | ## grid 3 : | ## grid 4 - {1::}set foldmethod=manual | - {1::}let x = 1 | - {1::}^ | + {1::}{7: }set foldmethod=manual foldcolumn=1 | + {1::}{7: }let x = 1 | + {1::}{7: }^ | {1:~ }| ]]) else screen:expect([[ - | + {7: } | {2:[No Name] }| - {1::}set foldmethod=manual | - {1::}let x = 1 | - {1::}^ | + {1::}{7: }set foldmethod=manual foldcolumn=1 | + {1::}{7: }let x = 1 | + {1::}{7: }^ | {1:~ }| {3:[Command Line] }| : | ]]) end - feed("kzfk") + feed('kzfk') if multigrid then screen:expect([[ ## grid 1 [2:---------------------------------------------]| {2:[No Name] }| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| - [4:---------------------------------------------]| + [4:---------------------------------------------]|*4 {3:[Command Line] }| [3:---------------------------------------------]| ## grid 2 - | + {7: } | ## grid 3 : | ## grid 4 - {1::}{5:^+-- 2 lines: set foldmethod=manual·········}| - {1::} | - {1:~ }| - {1:~ }| + {1::}{7:+}{5:^+-- 2 lines: set foldmethod=manual foldcol}| + {1::}{7: } | + {1:~ }|*2 ]]) else screen:expect([[ - | + {7: } | {2:[No Name] }| - {1::}{5:^+-- 2 lines: set foldmethod=manual·········}| - {1::} | - {1:~ }| - {1:~ }| + {1::}{7:+}{5:^+-- 2 lines: set foldmethod=manual foldcol}| + {1::}{7: } | + {1:~ }|*2 {3:[Command Line] }| : | ]]) end - feed("<cr>") + feed('<cr>') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {7: }^ | + {1:~ }|*6 ## grid 3 : | ]]) else screen:expect([[ - ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {7: }^ | + {1:~ }|*6 : | ]]) end - feed("/<c-f>") + feed('/<c-f>') if multigrid then screen:expect([[ ## grid 1 [2:---------------------------------------------]| {2:[No Name] }| - [5:---------------------------------------------]| - [5:---------------------------------------------]| - [5:---------------------------------------------]| - [5:---------------------------------------------]| + [5:---------------------------------------------]|*4 {3:[Command Line] }| [3:---------------------------------------------]| ## grid 2 - | + {7: } | ## grid 3 / | ## grid 5 - {1:/}alpha | - {1:/}{6:omega} | - {1:/}^ | + {1:/}{7: }alpha | + {1:/}{7: }{6:omega} | + {1:/}{7: }^ | {1:~ }| ]]) else screen:expect([[ - | + {7: } | {2:[No Name] }| - {1:/}alpha | - {1:/}{6:omega} | - {1:/}^ | + {1:/}{7: }alpha | + {1:/}{7: }{6:omega} | + {1:/}{7: }^ | {1:~ }| {3:[Command Line] }| / | ]]) end - feed("ggzfG") + feed('ggzfG') if multigrid then screen:expect([[ ## grid 1 [2:---------------------------------------------]| {2:[No Name] }| - [5:---------------------------------------------]| - [5:---------------------------------------------]| - [5:---------------------------------------------]| - [5:---------------------------------------------]| + [5:---------------------------------------------]|*4 {3:[Command Line] }| [3:---------------------------------------------]| ## grid 2 - | + {7: } | ## grid 3 / | ## grid 5 - {1:/}{5:^+-- 3 lines: alpha·························}| - {1:~ }| - {1:~ }| - {1:~ }| + {1:/}{7:+}{5:^+-- 3 lines: alpha························}| + {1:~ }|*3 ]]) else screen:expect([[ - | + {7: } | {2:[No Name] }| - {1:/}{5:^+-- 3 lines: alpha·························}| - {1:~ }| - {1:~ }| - {1:~ }| + {1:/}{7:+}{5:^+-- 3 lines: alpha························}| + {1:~ }|*3 {3:[Command Line] }| / | ]]) end - end) - it("work with autoresize", function() + it('foldcolumn autoresize', function() + fn.setline(1, 'line 1') + fn.setline(2, 'line 2') + fn.setline(3, 'line 3') + fn.setline(4, 'line 4') - funcs.setline(1, 'line 1') - funcs.setline(2, 'line 2') - funcs.setline(3, 'line 3') - funcs.setline(4, 'line 4') - - feed("zfj") - command("set foldcolumn=0") + feed('zfj') + command('set foldcolumn=0') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:^+-- 2 lines: line 1·························}| line 3 | line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ]]) @@ -1652,34 +1373,22 @@ describe("folded lines", function() {5:^+-- 2 lines: line 1·························}| line 3 | line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end -- should adapt to the current nesting of folds (e.g., 1) - command("set foldcolumn=auto:1") + command('set foldcolumn=auto:1') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+}{5:^+-- 2 lines: line 1························}| {7: }line 3 | {7: }line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ]]) @@ -1688,267 +1397,140 @@ describe("folded lines", function() {7:+}{5:^+-- 2 lines: line 1························}| {7: }line 3 | {7: }line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end - command("set foldcolumn=auto") + command('set foldcolumn=auto') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+}{5:^+-- 2 lines: line 1························}| {7: }line 3 | {7: }line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | - ]], unchanged=true} + ]], + unchanged = true, + } else - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:+}{5:^+-- 2 lines: line 1························}| {7: }line 3 | {7: }line 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]], unchanged=true} + ]], + unchanged = true, + } end -- fdc should not change with a new fold as the maximum is 1 - feed("zf3j") + feed('zf3j') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+}{5:^+-- 4 lines: line 1························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | ]]) else screen:expect([[ {7:+}{5:^+-- 4 lines: line 1························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end - command("set foldcolumn=auto:1") - if multigrid then screen:expect{grid=[[ + command('set foldcolumn=auto:1') + if multigrid then + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+}{5:^+-- 4 lines: line 1························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | - ]], unchanged=true} + ]], + unchanged = true, + } else - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:+}{5:^+-- 4 lines: line 1························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | - ]], unchanged=true} + ]], + unchanged = true, + } end -- relax the maximum fdc thus fdc should expand to -- accommodate the current number of folds - command("set foldcolumn=auto:4") + command('set foldcolumn=auto:4') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {7:+ }{5:^+-- 4 lines: line 1·······················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | ]]) else screen:expect([[ {7:+ }{5:^+-- 4 lines: line 1·······················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end end) - it('does not crash when foldtext is longer than columns #12988', function() + it('no crash when foldtext is longer than columns #12988', function() exec([[ function! MyFoldText() abort return repeat('-', &columns + 100) endfunction ]]) command('set foldtext=MyFoldText()') - feed("i<cr><esc>") - feed("vkzf") + feed('i<cr><esc>') + feed('vkzf') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:^---------------------------------------------}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | ]]) else screen:expect([[ {5:^---------------------------------------------}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end assert_alive() end) - it('work correctly with :move #18668', function() - screen:try_resize(45, 12) - exec([[ - set foldmethod=expr foldexpr=indent(v:lnum) - let content = ['', '', 'Line1', ' Line2', ' Line3', - \ 'Line4', ' Line5', ' Line6', - \ 'Line7', ' Line8', ' Line9'] - call append(0, content) - normal! zM - call cursor(4, 1) - move 2 - move 1 - ]]) - if multigrid then - screen:expect([[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [3:---------------------------------------------]| - ## grid 2 - | - {5:^+-- 2 lines: Line2··························}| - | - Line1 | - Line4 | - {5:+-- 2 lines: Line5··························}| - Line7 | - {5:+-- 2 lines: Line8··························}| - | - {1:~ }| - {1:~ }| - ## grid 3 - | - ]]) - else - screen:expect([[ - | - {5:^+-- 2 lines: Line2··························}| - | - Line1 | - Line4 | - {5:+-- 2 lines: Line5··························}| - Line7 | - {5:+-- 2 lines: Line8··························}| - | - {1:~ }| - {1:~ }| - | - ]]) - end - end) - it('fold text is shown when text has been scrolled to the right #19123', function() insert(content1) command('set number nowrap') @@ -1957,13 +1539,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {8: 1 }^This is a | @@ -1971,8 +1547,7 @@ describe("folded lines", function() {8: 3 }{5:+-- 2 lines: sentence composed by·······}| {8: 5 }in his cave. | {8: 6 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | ]]) @@ -1983,8 +1558,7 @@ describe("folded lines", function() {8: 3 }{5:+-- 2 lines: sentence composed by·······}| {8: 5 }in his cave. | {8: 6 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end @@ -1993,13 +1567,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {8: 1 }^his is a | @@ -2007,8 +1575,7 @@ describe("folded lines", function() {8: 3 }{5:+-- 2 lines: sentence composed by·······}| {8: 5 }n his cave. | {8: 6 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | ]]) @@ -2019,34 +1586,52 @@ describe("folded lines", function() {8: 3 }{5:+-- 2 lines: sentence composed by·······}| {8: 5 }n his cave. | {8: 6 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end end) it('fold attached virtual lines are drawn and scrolled correctly #21837', function() - funcs.setline(1, 'line 1') - funcs.setline(2, 'line 2') - funcs.setline(3, 'line 3') - funcs.setline(4, 'line 4') - feed("zfj") - local ns = meths.create_namespace('ns') - meths.buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 1", ""}}} }) - meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"virt_line below line 2", ""}}} }) - meths.buf_set_extmark(0, ns, 2, 0, { virt_lines_above = true, virt_lines = {{{"virt_line above line 3", ""}}} }) - meths.buf_set_extmark(0, ns, 3, 0, { virt_lines = {{{"virt_line below line 4", ""}}} }) - if multigrid then - screen:expect{grid=[[ - ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + fn.setline(1, 'line 1') + fn.setline(2, 'line 2') + fn.setline(3, 'line 3') + fn.setline(4, 'line 4') + feed('zfj') + local ns = api.nvim_create_namespace('ns') + api.nvim_buf_set_extmark( + 0, + ns, + 0, + 0, + { virt_lines_above = true, virt_lines = { { { 'virt_line above line 1', '' } } } } + ) + api.nvim_buf_set_extmark( + 0, + ns, + 1, + 0, + { virt_lines = { { { 'virt_line below line 2', '' } } } } + ) + api.nvim_buf_set_extmark( + 0, + ns, + 2, + 0, + { virt_lines_above = true, virt_lines = { { { 'virt_line above line 3', '' } } } } + ) + api.nvim_buf_set_extmark( + 0, + ns, + 3, + 0, + { virt_lines = { { { 'virt_line below line 4', '' } } } } + ) + if multigrid then + screen:expect { + grid = [[ + ## grid 1 + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:^+-- 2 lines: line 1·························}| @@ -2054,13 +1639,22 @@ describe("folded lines", function() line 3 | line 4 | virt_line below line 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 0, curcol = 0, linecount = 4, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 5, + curline = 0, + curcol = 0, + linecount = 4, + sum_scroll_delta = 0, + }, + }, + } else screen:expect([[ {5:^+-- 2 lines: line 1·························}| @@ -2068,62 +1662,53 @@ describe("folded lines", function() line 3 | line 4 | virt_line below line 4 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end feed('jzfj') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:+-- 2 lines: line 1·························}| {5:^+-- 2 lines: line 3·························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 5, curline = 2, curcol = 0, linecount = 4, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 5, + curline = 2, + curcol = 0, + linecount = 4, + sum_scroll_delta = 0, + }, + }, + } else screen:expect([[ {5:+-- 2 lines: line 1·························}| {5:^+-- 2 lines: line 3·························}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) end feed('kzo<C-Y>') - funcs.setline(5, 'line 5') + fn.setline(5, 'line 5') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 virt_line above line 1 | @@ -2135,9 +1720,19 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 6, + curline = 0, + curcol = 0, + linecount = 5, + sum_scroll_delta = -1, + }, + }, + } else screen:expect([[ virt_line above line 1 | @@ -2151,7 +1746,7 @@ describe("folded lines", function() ]]) end - meths.input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) + api.nvim_input_mouse('left', 'press', '', multigrid and 2 or 0, 4, 0) eq({ screencol = 1, screenrow = 5, @@ -2161,20 +1756,21 @@ describe("folded lines", function() line = 3, column = 1, coladd = 0, - }, funcs.getmousepos()) - - meths.buf_set_extmark(0, ns, 1, 0, { virt_lines = {{{"more virt_line below line 2", ""}}} }) + }, fn.getmousepos()) + + api.nvim_buf_set_extmark( + 0, + ns, + 1, + 0, + { virt_lines = { { { 'more virt_line below line 2', '' } } } } + ) feed('G<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 line 1 | @@ -2186,9 +1782,19 @@ describe("folded lines", function() {1:~ }| ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 0, + }, + }, + } else screen:expect([[ line 1 | @@ -2204,15 +1810,10 @@ describe("folded lines", function() feed('<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 line 2 | @@ -2220,13 +1821,22 @@ describe("folded lines", function() more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 1, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 1}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 1, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 1, + }, + }, + } else screen:expect([[ line 2 | @@ -2234,312 +1844,301 @@ describe("folded lines", function() more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end feed('<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 2, + }, + }, + } else screen:expect([[ virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end feed('<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 3, + }, + }, + } else screen:expect([[ more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end feed('<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 4}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 4, + }, + }, + } else screen:expect([[ {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) end feed('<C-E>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 4, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 5}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 4, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 5, + }, + }, + } else screen:expect([[ ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end feed('3<C-Y>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 2, + }, + }, + } else screen:expect([[ virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^line 5 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end - meths.input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) + api.nvim_input_mouse('left', 'press', '3', multigrid and 2 or 0, 3, 0) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^l{16:ine 5} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {11:-- VISUAL LINE --} | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 2}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 2, + }, + }, + } else screen:expect([[ virt_line below line 2 | more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^l{16:ine 5} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {11:-- VISUAL LINE --} | ]]) end - meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) + api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 0) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^l{16:ine 5} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 {11:-- VISUAL LINE --} | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 0, linecount = 5, sum_scroll_delta = 3}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 0, + linecount = 5, + sum_scroll_delta = 3, + }, + }, + } else screen:expect([[ more virt_line below line 2 | {5:+-- 2 lines: line 3·························}| ^l{16:ine 5} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {11:-- VISUAL LINE --} | ]]) end - meths.input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) + api.nvim_input_mouse('left', 'drag', '3', multigrid and 2 or 0, 7, 5) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {5:+-- 2 lines: line 3·························}| {16:line }^5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {11:-- VISUAL LINE --} | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 6, curline = 4, curcol = 5, linecount = 5, sum_scroll_delta = 4}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 2, + botline = 6, + curline = 4, + curcol = 5, + linecount = 5, + sum_scroll_delta = 4, + }, + }, + } else screen:expect([[ {5:+-- 2 lines: line 3·························}| {16:line }^5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {11:-- VISUAL LINE --} | ]]) end @@ -2547,12 +2146,10 @@ describe("folded lines", function() feed('<Esc>gg') command('botright 1split | wincmd w') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*4 {3:[No Name] [+] }| [4:---------------------------------------------]| {2:[No Name] [+] }| @@ -2566,10 +2163,28 @@ describe("folded lines", function() | ## grid 4 line 1 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 3, + curline = 0, + curcol = 0, + linecount = 5, + sum_scroll_delta = 0, + }, + [4] = { + win = 1001, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 5, + sum_scroll_delta = 0, + }, + }, + } else screen:expect([[ ^line 1 | @@ -2585,12 +2200,10 @@ describe("folded lines", function() feed('<C-Y>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*4 {3:[No Name] [+] }| [4:---------------------------------------------]| {2:[No Name] [+] }| @@ -2604,10 +2217,28 @@ describe("folded lines", function() | ## grid 4 line 1 | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = -1}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 5, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 3, + curline = 0, + curcol = 0, + linecount = 5, + sum_scroll_delta = -1, + }, + [4] = { + win = 1001, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 5, + sum_scroll_delta = 0, + }, + }, + } else screen:expect([[ virt_line above line 1 | @@ -2623,7 +2254,7 @@ describe("folded lines", function() end) it('Folded and Visual highlights are combined #19691', function() - command('hi! Visual guibg=Red') + command('hi! Visual guifg=NONE guibg=Red') insert([[ " foofoofoofoofoofoo " 口 {{{1 @@ -2640,13 +2271,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {14:" foofoofoofoofo}ofoo | @@ -2654,8 +2279,7 @@ describe("folded lines", function() {14:" barbarbarbarba}rbar | {15:+-- 3 lines: " }{5:口···························}| {14:" bazbazbazbazb}^azbaz | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2666,8 +2290,7 @@ describe("folded lines", function() {14:" barbarbarbarba}rbar | {15:+-- 3 lines: " }{5:口···························}| {14:" bazbazbazbazb}^azbaz | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2676,13 +2299,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {14:" foofoofoofoofoo}foo | @@ -2690,8 +2307,7 @@ describe("folded lines", function() {14:" barbarbarbarbar}bar | {15:+-- 3 lines: " 口}{5:···························}| {14:" bazbazbazbazba}^zbaz | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2702,8 +2318,7 @@ describe("folded lines", function() {14:" barbarbarbarbar}bar | {15:+-- 3 lines: " 口}{5:···························}| {14:" bazbazbazbazba}^zbaz | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2712,13 +2327,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {14:" foofoofoofoofoof}oo | @@ -2726,8 +2335,7 @@ describe("folded lines", function() {14:" barbarbarbarbarb}ar | {15:+-- 3 lines: " 口}{5:···························}| {14:" bazbazbazbazbaz}^baz | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2738,8 +2346,7 @@ describe("folded lines", function() {14:" barbarbarbarbarb}ar | {15:+-- 3 lines: " 口}{5:···························}| {14:" bazbazbazbazbaz}^baz | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2748,13 +2355,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {14:" foofoofoofoofoofoo} | @@ -2762,8 +2363,7 @@ describe("folded lines", function() {14:" barbarbarbarbarbar} | {15:+-- 3 lines: " 口··}{5:·························}| {14:" bazbazbazbazbazba}^z | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2774,8 +2374,7 @@ describe("folded lines", function() {14:" barbarbarbarbarbar} | {15:+-- 3 lines: " 口··}{5:·························}| {14:" bazbazbazbazbazba}^z | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2784,13 +2383,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 " foofoofoofoofo{14:ofoo} | @@ -2798,8 +2391,7 @@ describe("folded lines", function() " barbarbarbarba{14:rbar} | {5:+-- 3 lines: " }{15:口··}{5:·························}| " bazbazbazbazba^z{14:baz} | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2810,8 +2402,7 @@ describe("folded lines", function() " barbarbarbarba{14:rbar} | {5:+-- 3 lines: " }{15:口··}{5:·························}| " bazbazbazbazba^z{14:baz} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2820,13 +2411,7 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 " foofoofoofoofoo{14:foo} | @@ -2834,8 +2419,7 @@ describe("folded lines", function() " barbarbarbarbar{14:bar} | {5:+-- 3 lines: " }{15:口··}{5:·························}| " bazbazbazbazbaz^b{14:az} | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL BLOCK --} | ]]) @@ -2846,8 +2430,7 @@ describe("folded lines", function() " barbarbarbarbar{14:bar} | {5:+-- 3 lines: " }{15:口··}{5:·························}| " bazbazbazbazbaz^b{14:az} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL BLOCK --} | ]]) end @@ -2864,22 +2447,13 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {2:line} 1 | {5:+-- 2 lines: line 2·························}| {6:line} 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 /line^ | ]]) @@ -2888,34 +2462,22 @@ describe("folded lines", function() {2:line} 1 | {5:+-- 2 lines: line 2·························}| {6:line} 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 /line^ | ]]) end feed('<Esc>') - funcs.matchadd('Search', 'line') + fn.matchadd('Search', 'line') if multigrid then screen:expect([[ ## grid 1 - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| - [2:---------------------------------------------]| + [2:---------------------------------------------]|*7 [3:---------------------------------------------]| ## grid 2 {6:line} 1 | {5:+-- 2 lines: line 2·························}| {6:line} ^4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ]]) @@ -2924,28 +2486,29 @@ describe("folded lines", function() {6:line} 1 | {5:+-- 2 lines: line 2·························}| {6:line} ^4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end end) - it('support foldtext with virtual text format', function() + it('foldtext with virtual text format', function() screen:try_resize(30, 7) insert(content1) - command("hi! CursorLine guibg=NONE guifg=Red gui=NONE") + command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') command('hi F0 guibg=Red guifg=Black') command('hi F1 guifg=White') - meths.set_option_value('cursorline', true, {}) - meths.set_option_value('foldcolumn', '4', {}) - meths.set_option_value('foldtext', '[' - .. '["▶", ["F0", "F1"]], ' - .. '[v:folddashes], ' - .. '["\t", "Search"], ' - .. '[getline(v:foldstart), "NonText"]]', {}) + api.nvim_set_option_value('cursorline', true, {}) + api.nvim_set_option_value('foldcolumn', '4', {}) + api.nvim_set_option_value( + 'foldtext', + '[' + .. '["▶", ["F0", "F1"]], ' + .. '[v:folddashes], ' + .. '["\t", "Search"], ' + .. '[getline(v:foldstart), "NonText"]]', + {} + ) command('3,4fold') command('5,6fold') @@ -2953,20 +2516,12 @@ describe("folded lines", function() if multigrid then screen:expect([[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*6 [3:------------------------------]| ## grid 2 {7: }This is a | {7:+ }{4:^▶}{13:-}{17: }{18:valid English}{13:·····}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ]]) @@ -2974,33 +2529,24 @@ describe("folded lines", function() screen:expect([[ {7: }This is a | {7:+ }{4:^▶}{13:-}{17: }{18:valid English}{13:·····}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) end - eq('▶-\tvalid English', funcs.foldtextresult(2)) + eq('▶-\tvalid English', fn.foldtextresult(2)) feed('zo') if multigrid then screen:expect([[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*6 [3:------------------------------]| ## grid 2 {7: }This is a | {7:- }valid English | {7:│+ }{4:▶}{5:--}{19: }{18:sentence composed }| {7:│+ }{4:^▶}{13:--}{17: }{18:in his cave.}{13:······}| - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | ]]) @@ -3010,33 +2556,26 @@ describe("folded lines", function() {7:- }valid English | {7:│+ }{4:▶}{5:--}{19: }{18:sentence composed }| {7:│+ }{4:^▶}{13:--}{17: }{18:in his cave.}{13:······}| - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end - eq('▶--\tsentence composed by', funcs.foldtextresult(3)) - eq('▶--\tin his cave.', funcs.foldtextresult(5)) + eq('▶--\tsentence composed by', fn.foldtextresult(3)) + eq('▶--\tin his cave.', fn.foldtextresult(5)) - command('hi! Visual guibg=Red') + command('hi! Visual guifg=NONE guibg=Red') feed('V2k') if multigrid then screen:expect([[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*6 [3:------------------------------]| ## grid 2 {7: }This is a | {7:- }^v{14:alid English} | {7:│+ }{4:▶}{15:--}{19: }{20:sentence composed }| {7:│+ }{4:▶}{15:--}{19: }{20:in his cave.}{15:······}| - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {11:-- VISUAL LINE --} | ]]) @@ -3046,30 +2585,23 @@ describe("folded lines", function() {7:- }^v{14:alid English} | {7:│+ }{4:▶}{15:--}{19: }{20:sentence composed }| {7:│+ }{4:▶}{15:--}{19: }{20:in his cave.}{15:······}| - {1:~ }| - {1:~ }| + {1:~ }|*2 {11:-- VISUAL LINE --} | ]]) end - meths.set_option_value('rightleft', true, {}) + api.nvim_set_option_value('rightleft', true, {}) if multigrid then screen:expect([[ ## grid 1 - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| - [2:------------------------------]| + [2:------------------------------]|*6 [3:------------------------------]| ## grid 2 a si sihT{7: }| {14:hsilgnE dila}^v{7: -}| {20: desopmoc ecnetnes}{19: }{15:--}{4:▶}{7: +│}| {15:······}{20:.evac sih ni}{19: }{15:--}{4:▶}{7: +│}| - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 3 {11:-- VISUAL LINE --} | ]]) @@ -3079,15 +2611,128 @@ describe("folded lines", function() {14:hsilgnE dila}^v{7: -}| {20: desopmoc ecnetnes}{19: }{15:--}{4:▶}{7: +│}| {15:······}{20:.evac sih ni}{19: }{15:--}{4:▶}{7: +│}| - {1: ~}| - {1: ~}| + {1: ~}|*2 + {11:-- VISUAL LINE --} | + ]]) + end + end) + + it('transparent foldtext', function() + screen:try_resize(30, 7) + insert(content1) + command('hi! CursorLine guibg=NONE guifg=Red gui=NONE') + command('hi F0 guibg=Red guifg=Black') + command('hi F1 guifg=White') + api.nvim_set_option_value('cursorline', true, {}) + api.nvim_set_option_value('foldcolumn', '4', {}) + api.nvim_set_option_value('foldtext', '', {}) + + command('3,4fold') + command('5,6fold') + command('2,6fold') + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]|*6 + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:+ }{13:^valid English·············}| + {1:~ }|*4 + ## grid 3 + | + ]]) + else + screen:expect([[ + {7: }This is a | + {7:+ }{13:^valid English·············}| + {1:~ }|*4 + | + ]]) + end + + feed('zo') + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]|*6 + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:- }valid English | + {7:│+ }{5:sentence composed by······}| + {7:│+ }{13:^in his cave.··············}| + {1:~ }|*2 + ## grid 3 + | + ]]) + else + screen:expect([[ + {7: }This is a | + {7:- }valid English | + {7:│+ }{5:sentence composed by······}| + {7:│+ }{13:^in his cave.··············}| + {1:~ }|*2 + | + ]]) + end + + command('hi! Visual guifg=NONE guibg=Red') + feed('V2k') + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]|*6 + [3:------------------------------]| + ## grid 2 + {7: }This is a | + {7:- }^v{14:alid English} | + {7:│+ }{15:sentence composed by······}| + {7:│+ }{15:in his cave.··············}| + {1:~ }|*2 + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + {7: }This is a | + {7:- }^v{14:alid English} | + {7:│+ }{15:sentence composed by······}| + {7:│+ }{15:in his cave.··············}| + {1:~ }|*2 + {11:-- VISUAL LINE --} | + ]]) + end + + api.nvim_set_option_value('rightleft', true, {}) + if multigrid then + screen:expect([[ + ## grid 1 + [2:------------------------------]|*6 + [3:------------------------------]| + ## grid 2 + a si sihT{7: }| + {14:hsilgnE dila}^v{7: -}| + {15:······yb desopmoc ecnetnes}{7: +│}| + {15:··············.evac sih ni}{7: +│}| + {1: ~}|*2 + ## grid 3 + {11:-- VISUAL LINE --} | + ]]) + else + screen:expect([[ + a si sihT{7: }| + {14:hsilgnE dila}^v{7: -}| + {15:······yb desopmoc ecnetnes}{7: +│}| + {15:··············.evac sih ni}{7: +│}| + {1: ~}|*2 {11:-- VISUAL LINE --} | ]]) end end) end - describe("with ext_multigrid", function() + describe('with ext_multigrid', function() with_ext_multigrid(true) end) diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index 7776e024b0..727dc38829 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -5,9 +5,8 @@ local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert local command, exec = helpers.command, helpers.exec local eval = helpers.eval local feed_command, eq = helpers.feed_command, helpers.eq -local curbufmeths = helpers.curbufmeths -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local exec_lua = helpers.exec_lua describe('colorscheme compatibility', function() @@ -16,8 +15,8 @@ describe('colorscheme compatibility', function() end) it('&t_Co exists and is set to 256 by default', function() - eq(1, funcs.exists('&t_Co')) - eq(1, funcs.exists('+t_Co')) + eq(1, fn.exists('&t_Co')) + eq(1, fn.exists('+t_Co')) eq('256', eval('&t_Co')) end) end) @@ -30,13 +29,14 @@ describe('highlight: `:syntax manual`', function() before_each(function() clear() - screen = Screen.new(20,5) + screen = Screen.new(20, 5) screen:attach() - --syntax highlight for vimcscripts "echo" - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {bold=true, foreground=Screen.colors.Brown} - } ) + -- syntax highlight for vimscript's "echo" + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { bold = true, foreground = Screen.colors.Brown }, + [2] = { foreground = Screen.colors.Magenta1 }, + }) end) after_each(function() @@ -57,10 +57,8 @@ describe('highlight: `:syntax manual`', function() command('bn') feed_command('bp') screen:expect([[ - {1:^echo} 1 | - {0:~ }| - {0:~ }| - {0:~ }| + {1:^echo} {2:1} | + {0:~ }|*3 :bp | ]]) end) @@ -77,20 +75,17 @@ describe('highlight: `:syntax manual`', function() command('set nohidden') command('w') command('silent bn') - eq("tmp1.vim", eval("fnamemodify(bufname('%'), ':t')")) + eq('tmp1.vim', eval("fnamemodify(bufname('%'), ':t')")) feed_command('silent bp') - eq("Xtest-functional-ui-highlight.tmp.vim", eval("fnamemodify(bufname('%'), ':t')")) + eq('Xtest-functional-ui-highlight.tmp.vim', eval("fnamemodify(bufname('%'), ':t')")) screen:expect([[ - {1:^echo} 1 | - {0:~ }| - {0:~ }| - {0:~ }| + {1:^echo} {2:1} | + {0:~ }|*3 :silent bp | ]]) end) end) - describe('highlight defaults', function() local screen @@ -98,16 +93,16 @@ describe('highlight defaults', function() clear() screen = Screen.new() screen:set_default_attr_ids { - [0] = {bold=true, foreground=Screen.colors.Blue}; - [1] = {reverse = true, bold = true}; - [2] = {reverse = true}; - [3] = {bold = true}; - [4] = {bold = true, foreground = Screen.colors.SeaGreen}; - [5] = {foreground = Screen.colors.Red1, background = Screen.colors.WebGreen}; - [6] = {background = Screen.colors.Red1, foreground = Screen.colors.Grey100}; - [7] = {foreground = Screen.colors.Red}; - [8] = {foreground = Screen.colors.Blue}; - [9] = {italic = true}; + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { reverse = true, bold = true }, + [2] = { reverse = true }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen }, + [5] = { foreground = Screen.colors.Red1, background = Screen.colors.WebGreen }, + [6] = { background = Screen.colors.Red1, foreground = Screen.colors.Grey100 }, + [7] = { foreground = Screen.colors.Red }, + [8] = { foreground = Screen.colors.Blue }, + [9] = { italic = true }, } screen:attach() end) @@ -116,17 +111,10 @@ describe('highlight defaults', function() feed_command('sp', 'vsp', 'vsp') screen:expect([[ ^ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] }{2:[No Name] [No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {2:[No Name] }| :vsp | ]]) @@ -134,17 +122,10 @@ describe('highlight defaults', function() feed('<c-w>j') screen:expect([[ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {2:[No Name] [No Name] [No Name] }| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {1:[No Name] }| :vsp | ]]) @@ -154,51 +135,30 @@ describe('highlight defaults', function() feed('<c-w>k<c-w>l') screen:expect([[ │^ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {2:[No Name] }{1:[No Name] }{2:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {2:[No Name] }| :vsp | ]]) feed('<c-w>l') screen:expect([[ │ │^ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {2:[No Name] [No Name] }{1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {2:[No Name] }| :vsp | ]]) feed('<c-w>h<c-w>h') screen:expect([[ ^ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] }{2:[No Name] [No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {2:[No Name] }| :vsp | ]]) @@ -209,8 +169,7 @@ describe('highlight defaults', function() screen:try_resize(53, 4) screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:-- INSERT --} | ]]) end) @@ -219,8 +178,7 @@ describe('highlight defaults', function() screen:try_resize(53, 4) screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -243,8 +201,7 @@ describe('highlight defaults', function() feed('i') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 -- INSERT -- | ]]) feed('<esc>') @@ -253,8 +210,7 @@ describe('highlight defaults', function() feed('i') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {5:-- INSERT --} | ]]) end) @@ -266,16 +222,16 @@ describe('highlight defaults', function() insert('neovim') screen:expect([[ {6:neovi^m} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) - feed_command("hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE" - .. " gui=NONE guifg=NONE guibg=NONE guisp=NONE") + feed_command( + 'hi ErrorMsg term=NONE cterm=NONE ctermfg=NONE ctermbg=NONE' + .. ' gui=NONE guifg=NONE guibg=NONE guisp=NONE' + ) screen:expect([[ neovi^m | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -284,18 +240,19 @@ describe('highlight defaults', function() screen:try_resize(53, 4) screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) - feed_command("hi NonTextAlt guifg=Red") - feed_command("hi! link NonText NonTextAlt") - screen:expect([[ + feed_command('hi NonTextAlt guifg=Red') + feed_command('hi! link NonText NonTextAlt') + screen:expect( + [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :hi! link NonText NonTextAlt | - ]], {[0] = {foreground=Screen.colors.Red}}) + ]], + { [0] = { foreground = Screen.colors.Red } } + ) end) it('Cursor after `:hi clear|syntax reset` #6508', function() @@ -310,90 +267,199 @@ describe('highlight defaults', function() insert(' ne \t o\tv im ') screen:expect([[ ne{7:.>----.}o{7:>-----}v{7:..}im{7:*^*¬} | - {7:~ }| - {7:~ }| + {7:~ }|*2 | ]]) feed_command('highlight Whitespace gui=NONE guifg=#0000FF') screen:expect([[ ne{8:.>----.}o{8:>-----}v{8:..}im{8:*^*}{7:¬} | - {7:~ }| - {7:~ }| + {7:~ }|*2 :highlight Whitespace gui=NONE guifg=#0000FF | ]]) end) it('are sent to UIs', function() screen:try_resize(53, 4) - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}} + ]], + hl_groups = { EndOfBuffer = 0, MsgSeparator = 1 }, + } command('highlight EndOfBuffer gui=italic') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {9:~ }| - {9:~ }| + {9:~ }|*2 | - ]], hl_groups={EndOfBuffer=9, MsgSeparator=1}} + ]], + hl_groups = { EndOfBuffer = 9, MsgSeparator = 1 }, + } command('highlight clear EndOfBuffer') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], hl_groups={EndOfBuffer=0, MsgSeparator=1}} + ]], + hl_groups = { EndOfBuffer = 0, MsgSeparator = 1 }, + } end) end) describe('highlight', function() before_each(clear) - it('visual', function() - local screen = Screen.new(20,4) + it('Visual', function() + local screen = Screen.new(45, 5) screen:attach() screen:set_default_attr_ids({ - [1] = {background = Screen.colors.LightGrey}, - [2] = {bold = true, foreground = Screen.colors.Blue1}, - [3] = {bold = true}, + [1] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [2] = { bold = true, foreground = Screen.colors.Blue }, + [3] = { bold = true }, + [4] = { reverse = true, bold = true }, + [5] = { reverse = true }, + [6] = { background = Screen.colors.Grey90 }, }) insert([[ line1 foo bar + abcdefghijklmnopqrs + ABCDEFGHIJKLMNOPQRS ]]) + feed('gg') + command('vsplit') -- Non-blinking block cursor: does NOT highlight char-at-cursor. command('set guicursor=a:block-blinkon0') - feed('gg$vhhh') + feed('V') screen:expect([[ - line1 foo^ {1:bar} | - | - {2:~ }| - {3:-- VISUAL --} | + {1: }^l{1:ine1 foo bar} │{1: line1 foo bar} | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL LINE --} | + ]]) + + feed('<Esc>$vhhh') + screen:expect([[ + line1 foo^ {1:bar} │ line1 foo{1: bar} | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL --} | ]]) -- Vertical cursor: highlights char-at-cursor. #8983 command('set guicursor=a:block-blinkon175') screen:expect([[ - line1 foo{1:^ bar} | - | - {2:~ }| - {3:-- VISUAL --} | + line1 foo{1:^ bar} │ line1 foo{1: bar} | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL --} | + ]]) + + command('set selection=exclusive') + screen:expect([[ + line1 foo{1:^ ba}r │ line1 foo{1: ba}r | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL --} | + ]]) + + feed('o') + screen:expect([[ + line1 foo{1: ba}^r │ line1 foo{1: ba}r | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL --} | + ]]) + + feed('V') + screen:expect([[ + {1: line1 foo ba^r} │{1: line1 foo bar} | + abcdefghijklmnopqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL LINE --} | + ]]) + + command('set cursorcolumn') + feed('<C-V>') + screen:expect([[ + line1 foo{1: ba}^r │ line1 foo{1: ba}r | + abcdefghijklmn{6:o}pqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMN{6:O}PQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | + ]]) + + command('set selection&') + screen:expect([[ + line1 foo{1: ba^r} │ line1 foo{1: bar} | + abcdefghijklmn{6:o}pqrs │abcdefghijklmnopqrs | + ABCDEFGHIJKLMN{6:O}PQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | + ]]) + + feed('^') + screen:expect([[ + {1:^line1 foo }bar │ {1:line1 foo }bar | + ab{6:c}defghijklmnopqrs │abcdefghijklmnopqrs | + AB{6:C}DEFGHIJKLMNOPQRS │ABCDEFGHIJKLMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | + ]]) + + feed('2j') + screen:expect([[ + {1:line1 foo }bar │ {1:line1 foo }bar | + ab{1:cdefghijkl}mnopqrs │ab{1:cdefghijkl}mnopqrs | + AB{1:^CDEFGHIJKL}MNOPQRS │AB{1:CDEFGHIJKL}MNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | + ]]) + + command('set nocursorcolumn') + feed('O') + screen:expect([[ + {1:line1 foo }bar │ {1:line1 foo }bar | + ab{1:cdefghijkl}mnopqrs │ab{1:cdefghijkl}mnopqrs | + AB{1:CDEFGHIJK^L}MNOPQRS │AB{1:CDEFGHIJKL}MNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | + ]]) + + command('set selection=exclusive') + screen:expect([[ + {1:line1 foo} bar │ {1:line1 foo} bar | + ab{1:cdefghijk}lmnopqrs │ab{1:cdefghijk}lmnopqrs | + AB{1:CDEFGHIJK}^LMNOPQRS │AB{1:CDEFGHIJK}LMNOPQRS | + {4:[No Name] [+] }{5:[No Name] [+] }| + {3:-- VISUAL BLOCK --} | ]]) end) it('cterm=standout gui=standout', function() - local screen = Screen.new(20,5) + local screen = Screen.new(20, 5) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {standout = true, bold = true, underline = true, - background = Screen.colors.Gray90, foreground = Screen.colors.Blue1}, - [3] = {standout = true, underline = true, - background = Screen.colors.Gray90} + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { + standout = true, + bold = true, + underline = true, + background = Screen.colors.Gray90, + foreground = Screen.colors.Blue1, + }, + [3] = { standout = true, underline = true, background = Screen.colors.Gray90 }, }) feed_command('hi CursorLine cterm=standout,underline gui=standout,underline') feed_command('set cursorline') @@ -409,7 +475,7 @@ describe('highlight', function() end) it('strikethrough', function() - local screen = Screen.new(25,6) + local screen = Screen.new(25, 6) screen:attach() feed_command('syntax on') feed_command('syn keyword TmpKeyword foo') @@ -420,27 +486,34 @@ describe('highlight', function() foo bar foobarfoobar ]]) - screen:expect([[ + screen:expect( + [[ {1:foo} | {1:foo} bar | foobarfoobar | ^ | {2:~ }| | - ]], { - [1] = {strikethrough = true}, - [2] = {bold = true, foreground = Screen.colors.Blue1}, - }) + ]], + { + [1] = { strikethrough = true }, + [2] = { bold = true, foreground = Screen.colors.Blue1 }, + } + ) end) it('nocombine', function() - local screen = Screen.new(25,6) - screen:set_default_attr_ids{ - [1] = {foreground = Screen.colors.SlateBlue, underline = true}, - [2] = {bold = true, foreground = Screen.colors.Blue1}, - [3] = {underline = true, reverse = true, foreground = Screen.colors.SlateBlue}, - [4] = {background = Screen.colors.Yellow, reverse = true, foreground = Screen.colors.SlateBlue}, - [5] = {foreground = Screen.colors.Red}, + local screen = Screen.new(25, 6) + screen:set_default_attr_ids { + [1] = { foreground = Screen.colors.SlateBlue, underline = true }, + [2] = { bold = true, foreground = Screen.colors.Blue1 }, + [3] = { underline = true, reverse = true, foreground = Screen.colors.SlateBlue }, + [4] = { + background = Screen.colors.Yellow, + reverse = true, + foreground = Screen.colors.SlateBlue, + }, + [5] = { foreground = Screen.colors.Red }, } screen:attach() feed_command('syntax on') @@ -451,37 +524,39 @@ describe('highlight', function() foobar foobar ]]) - screen:expect{grid=[[ - {1:foobar} | - {1:foobar} | + screen:expect { + grid = [[ + {1:foobar} |*2 ^ | - {2:~ }| - {2:~ }| + {2:~ }|*2 | - ]]} + ]], + } feed('/foo') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:foo}{1:bar} | {4:foo}{1:bar} | | - {2:~ }| - {2:~ }| + {2:~ }|*2 /foo^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {4:^foo}{1:bar} | {4:foo}{1:bar} | | - {2:~ }| - {2:~ }| + {2:~ }|*2 {5:search hit...uing at TOP} | - ]]} + ]], + } end) it('guisp (special/undercurl)', function() - local screen = Screen.new(25,10) + local screen = Screen.new(25, 10) screen:attach() feed_command('syntax on') feed_command('syn keyword TmpKeyword neovim') @@ -505,7 +580,8 @@ describe('highlight', function() specialwithfg ]]) feed('Go<tab>neovim tabbed') - screen:expect([[ + screen:expect( + [[ {1:neovim} | awesome {1:neovim} | wordcontainingneovim | @@ -516,20 +592,24 @@ describe('highlight', function() {1:neovim} tabbed^ | {0:~ }| {5:-- INSERT --} | - ]], { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {background = Screen.colors.Yellow, foreground = Screen.colors.Red, - special = Screen.colors.Red}, - [2] = {special = Screen.colors.Red}, - [3] = {special = Screen.colors.Red, background = Screen.colors.Yellow}, - [4] = {foreground = Screen.colors.Red, special = Screen.colors.Red}, - [5] = {bold=true}, - }) - + ]], + { + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { + background = Screen.colors.Yellow, + foreground = Screen.colors.Red, + special = Screen.colors.Red, + }, + [2] = { special = Screen.colors.Red }, + [3] = { special = Screen.colors.Red, background = Screen.colors.Yellow }, + [4] = { foreground = Screen.colors.Red, special = Screen.colors.Red }, + [5] = { bold = true }, + } + ) end) it("'diff', syntax and extmark #23722", function() - local screen = Screen.new(25,10) + local screen = Screen.new(25, 10) screen:attach() exec([[ new @@ -539,28 +619,34 @@ describe('highlight', function() syn match WarningMsg "^.*$" call nvim_buf_add_highlight(0, -1, 'ErrorMsg', 1, 2, 8) ]]) - screen:expect([[ + screen:expect( + [[ {1: }^ | {1: }{2:01}{3:234 67}{2:89}{5: }| - {4:~ }| - {4:~ }| + {4:~ }|*2 {7:[No Name] [+] }| {1: } | {1: }{6:-----------------------}| {4:~ }| {8:[No Name] }| | - ]], { - [0] = {Screen.colors.WebGray, foreground = Screen.colors.DarkBlue}, - [1] = {background = Screen.colors.Grey, foreground = Screen.colors.Blue4}, - [2] = {foreground = Screen.colors.Red, background = Screen.colors.LightBlue}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.LightBlue}, - [4] = {bold = true, foreground = Screen.colors.Blue}, - [5] = {background = Screen.colors.LightBlue}, - [6] = {bold = true, background = Screen.colors.LightCyan, foreground = Screen.colors.Blue1}, - [7] = {reverse = true, bold = true}, - [8] = {reverse = true}, - }) + ]], + { + [0] = { Screen.colors.WebGray, foreground = Screen.colors.DarkBlue }, + [1] = { background = Screen.colors.Grey, foreground = Screen.colors.Blue4 }, + [2] = { foreground = Screen.colors.Red, background = Screen.colors.LightBlue }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.LightBlue }, + [4] = { bold = true, foreground = Screen.colors.Blue }, + [5] = { background = Screen.colors.LightBlue }, + [6] = { + bold = true, + background = Screen.colors.LightCyan, + foreground = Screen.colors.Blue1, + }, + [7] = { reverse = true, bold = true }, + [8] = { reverse = true }, + } + ) end) end) @@ -569,62 +655,55 @@ describe("'listchars' highlight", function() before_each(function() clear() - screen = Screen.new(20,5) + screen = Screen.new(20, 5) screen:attach() end) it("'cursorline' and 'cursorcolumn'", function() screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {background=Screen.colors.Grey90} + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.Grey90 }, }) feed_command('highlight clear ModeMsg') feed_command('set cursorline') feed('i') screen:expect([[ {1:^ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 -- INSERT -- | ]]) feed('abcdefg<cr>kkasdf') screen:expect([[ abcdefg | {1:kkasdf^ }| - {0:~ }| - {0:~ }| + {0:~ }|*2 -- INSERT -- | ]]) feed('<esc>') screen:expect([[ abcdefg | {1:kkasd^f }| - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed_command('set nocursorline') screen:expect([[ abcdefg | kkasd^f | - {0:~ }| - {0:~ }| + {0:~ }|*2 :set nocursorline | ]]) feed('k') screen:expect([[ abcde^fg | kkasdf | - {0:~ }| - {0:~ }| + {0:~ }|*2 :set nocursorline | ]]) feed('jjji<cr><cr><cr><esc>') screen:expect([[ kkasd | - | - | + |*2 ^f | | ]]) @@ -650,22 +729,22 @@ describe("'listchars' highlight", function() it("'cursorline' and with 'listchars' option", function() screen:set_default_attr_ids({ - [1] = {background=Screen.colors.Grey90}, + [1] = { background = Screen.colors.Grey90 }, [2] = { - foreground=Screen.colors.Red, - background=Screen.colors.Grey90, + foreground = Screen.colors.Red, + background = Screen.colors.Grey90, }, [3] = { - background=Screen.colors.Grey90, - foreground=Screen.colors.Blue, - bold=true, + background = Screen.colors.Grey90, + foreground = Screen.colors.Blue, + bold = true, }, [4] = { - foreground=Screen.colors.Blue, - bold=true, + foreground = Screen.colors.Blue, + bold = true, }, [5] = { - foreground=Screen.colors.Red, + foreground = Screen.colors.Red, }, }) feed_command('highlight clear ModeMsg') @@ -717,8 +796,7 @@ describe("'listchars' highlight", function() feed('$') screen:expect([[ {3:<}{1:r}{2:.}{1:sit}{2:.}{1:ame^t}{3:¬}{1: }| - {4:<} | - {4:<} | + {4:<} |*2 {4:~ }| :set cursorline | ]]) @@ -734,66 +812,42 @@ describe("'listchars' highlight", function() it("'listchar' with wrap", function() screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, + [0] = { bold = true, foreground = Screen.colors.Blue }, }) feed_command('set wrap') feed_command('set listchars=eol:¬,precedes:< list') feed('90ia<esc>') screen:expect([[ {0:<}aaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaa| + aaaaaaaaaaaaaaaaaaaa|*2 aaaaaaaaa^a{0:¬} | | ]]) feed('0') screen:expect([[ ^aaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaa| + aaaaaaaaaaaaaaaaaaaa|*3 | ]]) end) it("'listchar' in visual mode", function() screen:set_default_attr_ids({ - [1] = {background=Screen.colors.Grey90}, - [2] = { - foreground=Screen.colors.Red, - background=Screen.colors.Grey90, - }, - [3] = { - background=Screen.colors.Grey90, - foreground=Screen.colors.Blue, - bold=true, - }, - [4] = { - foreground=Screen.colors.Blue, - bold=true, - }, - [5] = { - foreground=Screen.colors.Red, - }, - [6] = { - background=Screen.colors.LightGrey, - }, - [7] = { - background=Screen.colors.LightGrey, - foreground=Screen.colors.Red, - }, - [8] = { - background=Screen.colors.LightGrey, - foreground=Screen.colors.Blue, - bold=true, - }, + [1] = { background = Screen.colors.Grey90 }, + [2] = { foreground = Screen.colors.Red, background = Screen.colors.Grey90 }, + [3] = { background = Screen.colors.Grey90, foreground = Screen.colors.Blue, bold = true }, + [4] = { foreground = Screen.colors.Blue, bold = true }, + [5] = { foreground = Screen.colors.Red }, + [6] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, + [7] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Red }, + [8] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Blue, bold = true }, }) - feed_command('highlight clear ModeMsg') - feed_command('highlight Whitespace guifg=#FF0000') - feed_command('set cursorline') - feed_command('set tabstop=8') - feed_command('set nowrap') - feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') + command('highlight clear ModeMsg') + command('highlight Whitespace guifg=#FF0000') + command('set cursorline') + command('set tabstop=8') + command('set nowrap') + command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') feed('i\t abcd <cr>\t abcd Lorem ipsum dolor sit amet<cr><esc>kkk0') screen:expect([[ {2:^>-------.}{1:abcd}{2:*}{3:¬}{1: }| @@ -830,10 +884,10 @@ describe("'listchars' highlight", function() it("'cursorline' with :match", function() screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {background=Screen.colors.Grey90}, - [2] = {foreground=Screen.colors.Red}, - [3] = {foreground=Screen.colors.X11Green, background=Screen.colors.Red1}, + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.Grey90 }, + [2] = { foreground = Screen.colors.Red }, + [3] = { foreground = Screen.colors.X11Green, background = Screen.colors.Red1 }, }) feed_command('highlight clear ModeMsg') feed_command('highlight Whitespace guifg=#FF0000') @@ -842,25 +896,19 @@ describe("'listchars' highlight", function() feed('ia \t bc \t <esc>') screen:expect([[ a bc ^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed_command('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list') screen:expect([[ a{2:.>-----.}bc{2:*>---*^*}{0:¬} | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed_command('match Error /\\s\\+$/') screen:expect([[ a{2:.>-----.}bc{3:*>---*^*}{0:¬} | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -870,15 +918,15 @@ describe('CursorLine and CursorLineNr highlights', function() before_each(clear) it('overridden by Error, ColorColumn if fg not set', function() - local screen = Screen.new(50,5) + local screen = Screen.new(50, 5) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.SlateBlue}, - [2] = {bold = true, foreground = Screen.colors.Brown}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90}, - [5] = {background = Screen.colors.Gray90}, - [6] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {background = Screen.colors.LightRed}, + [1] = { foreground = Screen.colors.SlateBlue }, + [2] = { bold = true, foreground = Screen.colors.Brown }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 }, + [5] = { background = Screen.colors.Gray90 }, + [6] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { background = Screen.colors.LightRed }, }) screen:attach() @@ -906,12 +954,12 @@ describe('CursorLine and CursorLineNr highlights', function() end) it("overridden by NonText in 'showbreak' characters", function() - local screen = Screen.new(20,5) + local screen = Screen.new(20, 5) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Yellow, background = Screen.colors.Blue}; - [2] = {foreground = Screen.colors.Black, background = Screen.colors.White}; - [3] = {foreground = Screen.colors.Yellow, background = Screen.colors.White}; - [4] = {foreground = Screen.colors.Yellow}; + [1] = { foreground = Screen.colors.Yellow, background = Screen.colors.Blue }, + [2] = { foreground = Screen.colors.Black, background = Screen.colors.White }, + [3] = { foreground = Screen.colors.Yellow, background = Screen.colors.White }, + [4] = { foreground = Screen.colors.Yellow }, }) screen:attach() @@ -957,13 +1005,13 @@ describe('CursorLine and CursorLineNr highlights', function() end) it("'cursorlineopt' screenline", function() - local screen = Screen.new(20,5) + local screen = Screen.new(20, 5) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Black, background = Screen.colors.White}; - [2] = {foreground = Screen.colors.Yellow}; - [3] = {foreground = Screen.colors.Red, background = Screen.colors.Green}; - [4] = {foreground = Screen.colors.Green, background = Screen.colors.Red}; - [5] = {bold = true}, -- ModeMsg + [1] = { foreground = Screen.colors.Black, background = Screen.colors.White }, + [2] = { foreground = Screen.colors.Yellow }, + [3] = { foreground = Screen.colors.Red, background = Screen.colors.Green }, + [4] = { foreground = Screen.colors.Green, background = Screen.colors.Red }, + [5] = { bold = true }, -- ModeMsg }) screen:attach() @@ -1088,16 +1136,16 @@ describe('CursorLine and CursorLineNr highlights', function() -- oldtest: Test_cursorline_after_yank() it('always updated. vim-patch:8.1.0849', function() - local screen = Screen.new(50,5) + local screen = Screen.new(50, 5) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.SlateBlue}, - [2] = {bold = true, foreground = Screen.colors.Brown}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90}, - [5] = {background = Screen.colors.Gray90}, - [6] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {background = Screen.colors.LightRed}, - [8] = {foreground = Screen.colors.Brown}, + [1] = { foreground = Screen.colors.SlateBlue }, + [2] = { bold = true, foreground = Screen.colors.Brown }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 }, + [5] = { background = Screen.colors.Gray90 }, + [6] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { background = Screen.colors.LightRed }, + [8] = { foreground = Screen.colors.Brown }, }) screen:attach() command('set cursorline relativenumber') @@ -1122,18 +1170,18 @@ describe('CursorLine and CursorLineNr highlights', function() -- oldtest: Test_cursorline_with_visualmode() it('with visual area. vim-patch:8.1.1001', function() - local screen = Screen.new(50,5) + local screen = Screen.new(50, 5) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.SlateBlue}, - [2] = {bold = true, foreground = Screen.colors.Brown}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [4] = {foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90}, - [5] = {background = Screen.colors.Gray90}, - [6] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {background = Screen.colors.LightRed}, - [8] = {foreground = Screen.colors.Brown}, - [9] = {background = Screen.colors.LightGrey}, - [10] = {bold = true}, + [1] = { foreground = Screen.colors.SlateBlue }, + [2] = { bold = true, foreground = Screen.colors.Brown }, + [3] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [4] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Gray90 }, + [5] = { background = Screen.colors.Gray90 }, + [6] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { background = Screen.colors.LightRed }, + [8] = { foreground = Screen.colors.Brown }, + [9] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [10] = { bold = true }, }) screen:attach() command('set cursorline') @@ -1142,8 +1190,7 @@ describe('CursorLine and CursorLineNr highlights', function() screen:expect([[ {9:abc} | ^a{9:bc} | - abc | - abc | + abc |*2 {10:-- VISUAL LINE --} | ]]) end) @@ -1152,8 +1199,8 @@ describe('CursorLine and CursorLineNr highlights', function() it('is updated if cursor is moved up from timer vim-patch:8.2.4591', function() local screen = Screen.new(50, 8) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Gray90}, -- CursorLine - [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText + [1] = { background = Screen.colors.Gray90 }, -- CursorLine + [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText }) screen:attach() exec([[ @@ -1167,40 +1214,41 @@ describe('CursorLine and CursorLineNr highlights', function() call timer_start(300, 'Func') ]]) - screen:expect({grid = [[ + screen:expect({ + grid = [[ aaaaa | bbbbb | ccccc | {1:^ddddd }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | - ]], timeout = 100}) - screen:expect({grid = [[ + ]], + timeout = 100, + }) + screen:expect({ + grid = [[ aaaaa | {1:^bbbbb }| ccccc | ddddd | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | - ]]}) + ]], + }) end) it('with split windows in diff mode', function() - local screen = Screen.new(50,12) + local screen = Screen.new(50, 12) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [2] = {bold = true, background = Screen.colors.Red}, - [3] = {background = Screen.colors.LightMagenta}, - [4] = {reverse = true}, - [5] = {background = Screen.colors.LightBlue}, - [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [7] = {background = Screen.colors.Red, foreground = Screen.colors.White}, - [8] = {bold = true, foreground = Screen.colors.Blue1}, - [9] = {bold = true, reverse = true}, + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [2] = { bold = true, background = Screen.colors.Red }, + [3] = { background = Screen.colors.LightMagenta }, + [4] = { reverse = true }, + [5] = { background = Screen.colors.LightBlue }, + [6] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 }, + [7] = { background = Screen.colors.Red, foreground = Screen.colors.White }, + [8] = { bold = true, foreground = Screen.colors.Blue1 }, + [9] = { bold = true, reverse = true }, }) screen:attach() @@ -1210,20 +1258,19 @@ describe('CursorLine and CursorLineNr highlights', function() feed('<esc>gg') command('vsplit') command('enew') - feed('iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>') + feed( + 'iline 1 some text<cr>line 2 moRe text!<cr>extra line!<cr>extra line!<cr>extra line!<cr>last line ...<cr>' + ) feed('<esc>gg') command('windo diffthis') screen:expect([[ {1: }{7:line 1 some text }│{1: }{7:^line 1 some text }| {1: }{3:line 2 mo}{2:Re text!}{3: }│{1: }{3:line 2 mo}{2:re text}{3: }| {1: }{5:extra line! }│{1: }{6:----------------------}| - {1: }extra line! │{1: }extra line! | - {1: }extra line! │{1: }extra line! | + {1: }extra line! │{1: }extra line! |*2 {1: }last line ... │{1: }last line ... | {1: } │{1: } | - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| + {8:~ }│{8:~ }|*3 {4:[No Name] [+] }{9:[No Name] [+] }| | ]]) @@ -1232,13 +1279,10 @@ describe('CursorLine and CursorLineNr highlights', function() {1: }line 1 some text │{1: }line 1 some text | {1: }{3:line 2 mo}{2:Re text!}{3: }│{1: }{3:line 2 mo}{2:re text}{3: }| {1: }{5:extra line! }│{1: }{6:----------------------}| - {1: }extra line! │{1: }extra line! | - {1: }extra line! │{1: }extra line! | + {1: }extra line! │{1: }extra line! |*2 {1: }last line ... │{1: }last line ... | {1: }{7: }│{1: }{7:^ }| - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| + {8:~ }│{8:~ }|*3 {4:[No Name] [+] }{9:[No Name] [+] }| | ]]) @@ -1247,50 +1291,52 @@ describe('CursorLine and CursorLineNr highlights', function() -- Rendered as underline in a diff-line. #9028 command('hi CursorLine ctermbg=red ctermfg=NONE guibg=red guifg=NONE') feed('kkkk') - screen:expect([[ + screen:expect( + [[ {1: }line 1 some text │{1: }line 1 some text | {1: }{11:line 2 mo}{12:Re text!}{11: }│{1: }{11:^line 2 mo}{12:re text}{11: }| {1: }{5:extra line! }│{1: }{6:----------------------}| - {1: }extra line! │{1: }extra line! | - {1: }extra line! │{1: }extra line! | + {1: }extra line! │{1: }extra line! |*2 {1: }last line ... │{1: }last line ... | {1: } │{1: } | - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| - {8:~ }│{8:~ }| + {8:~ }│{8:~ }|*3 {4:[No Name] [+] }{9:[No Name] [+] }| | - ]], { - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [2] = {bold = true, background = Screen.colors.Red}, - [3] = {background = Screen.colors.LightMagenta}, - [4] = {reverse = true}, - [5] = {background = Screen.colors.LightBlue}, - [6] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [7] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [8] = {bold = true, foreground = Screen.colors.Blue1}, - [9] = {bold = true, reverse = true}, - [10] = {bold = true}, - [11] = {underline = true, - background = Screen.colors.LightMagenta}, - [12] = {bold = true, underline = true, - background = Screen.colors.Red}, - }) + ]], + { + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [2] = { bold = true, background = Screen.colors.Red }, + [3] = { background = Screen.colors.LightMagenta }, + [4] = { reverse = true }, + [5] = { background = Screen.colors.LightBlue }, + [6] = { + background = Screen.colors.LightCyan1, + bold = true, + foreground = Screen.colors.Blue1, + }, + [7] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [8] = { bold = true, foreground = Screen.colors.Blue1 }, + [9] = { bold = true, reverse = true }, + [10] = { bold = true }, + [11] = { underline = true, background = Screen.colors.LightMagenta }, + [12] = { bold = true, underline = true, background = Screen.colors.Red }, + } + ) end) -- oldtest: Test_diff_with_cursorline_number() it('CursorLineNr shows correctly just below filler lines', function() - local screen = Screen.new(50,12) + local screen = Screen.new(50, 12) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray}, - [2] = {background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1}, - [3] = {reverse = true}, - [4] = {background = Screen.colors.LightBlue}, - [5] = {background = Screen.colors.Red, foreground = Screen.colors.White}, - [6] = {background = Screen.colors.White, bold = true, foreground = Screen.colors.Black}, - [7] = {bold = true, foreground = Screen.colors.Blue1}, - [8] = {bold = true, reverse = true}, - [9] = {foreground = Screen.colors.Brown}, + [1] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGray }, + [2] = { background = Screen.colors.LightCyan1, bold = true, foreground = Screen.colors.Blue1 }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightBlue }, + [5] = { background = Screen.colors.Red, foreground = Screen.colors.White }, + [6] = { background = Screen.colors.White, bold = true, foreground = Screen.colors.Black }, + [7] = { bold = true, foreground = Screen.colors.Blue1 }, + [8] = { bold = true, reverse = true }, + [9] = { foreground = Screen.colors.Brown }, }) screen:attach() @@ -1308,12 +1354,7 @@ describe('CursorLine and CursorLineNr highlights', function() {1: }{6: 1 }{5:^foo }│{1: }{6: 2 }{5:foo }| {1: }{9: 2 }foo │{1: }{9: 3 }foo | {1: }{9: 3 }bar │{1: }{9: 4 }bar | - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| + {7:~ }│{7:~ }|*6 {8:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -1323,12 +1364,7 @@ describe('CursorLine and CursorLineNr highlights', function() {1: }{6: 1 }^foo │{1: }{6: 2 }{5:foo }| {1: }{9: 2 }foo │{1: }{9: 3 }foo | {1: }{9: 3 }bar │{1: }{9: 4 }bar | - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| - {7:~ }│{7:~ }| + {7:~ }│{7:~ }|*6 {8:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -1341,9 +1377,9 @@ describe('CursorColumn highlight', function() clear() screen = Screen.new(50, 8) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Gray90}, -- CursorColumn - [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText - [3] = {bold = true}, -- ModeMsg + [1] = { background = Screen.colors.Gray90 }, -- CursorColumn + [2] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText + [3] = { bold = true }, -- ModeMsg }) screen:attach() end) @@ -1357,44 +1393,28 @@ describe('CursorColumn highlight', function() screen:expect([[ 1234567{1:8}9 | a ^ b | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 | ]]) feed('i') screen:expect([[ 1{1:2}3456789 | a^ b | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 {3:-- INSERT --} | ]]) feed('<C-O>') screen:expect([[ 1234567{1:8}9 | a ^ b | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 {3:-- (insert) --} | ]]) feed('i') screen:expect([[ 1{1:2}3456789 | a^ b | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 {3:-- INSERT --} | ]]) end) @@ -1412,26 +1432,27 @@ describe('CursorColumn highlight', function() call timer_start(300, 'Func') ]]) - screen:expect({grid = [[ + screen:expect({ + grid = [[ aaaa{1:a} | bbbb{1:b} | cccc{1:c} | dddd^d | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | - ]], timeout = 100}) - screen:expect({grid = [[ + ]], + timeout = 100, + }) + screen:expect({ + grid = [[ ^aaaaa | {1:b}bbbb | {1:c}cccc | {1:d}dddd | - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*3 | - ]]}) + ]], + }) end) end) @@ -1442,15 +1463,15 @@ describe('ColorColumn highlight', function() clear() screen = Screen.new(40, 15) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.LightRed}, -- ColorColumn - [2] = {background = Screen.colors.Grey90}, -- CursorLine - [3] = {foreground = Screen.colors.Brown}, -- LineNr - [4] = {foreground = Screen.colors.Brown, bold = true}, -- CursorLineNr - [5] = {foreground = Screen.colors.Blue, bold = true}, -- NonText - [6] = {foreground = Screen.colors.Blue, background = Screen.colors.LightRed, bold = true}, - [7] = {reverse = true, bold = true}, -- StatusLine - [8] = {reverse = true}, -- StatusLineNC - [9] = {background = Screen.colors.Grey90, foreground = Screen.colors.Red}, + [1] = { background = Screen.colors.LightRed }, -- ColorColumn + [2] = { background = Screen.colors.Grey90 }, -- CursorLine + [3] = { foreground = Screen.colors.Brown }, -- LineNr + [4] = { foreground = Screen.colors.Brown, bold = true }, -- CursorLineNr + [5] = { foreground = Screen.colors.Blue, bold = true }, -- NonText + [6] = { foreground = Screen.colors.Blue, background = Screen.colors.LightRed, bold = true }, + [7] = { reverse = true, bold = true }, -- StatusLine + [8] = { reverse = true }, -- StatusLineNC + [9] = { background = Screen.colors.Grey90, foreground = Screen.colors.Red }, }) screen:attach() end) @@ -1472,16 +1493,12 @@ describe('ColorColumn highlight', function() {4: 1 }11{1:1}11111{1:1}1 | {3: 2 }22{1:2}22222{1:2}22 | {3: 3 }33{1:3}33333{1:3}3 | - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*3 {8:X }| {4: 1 }^11{1:1}11111{1:1}1 | {3: 2 }22{1:2}22222{1:2}22 | {3: 3 }33{1:3}33333{1:3}3 | - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*3 {7:X }| | ]]) @@ -1496,18 +1513,7 @@ describe('ColorColumn highlight', function() screen:expect([[ ^The quick brown fox jumped over the {1: }| {1: } {1:l}azy dogs | - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*12 | ]]) end) @@ -1521,18 +1527,7 @@ describe('ColorColumn highlight', function() screen:expect([[ ^The quick brown fox jumped over the laz{1:y}| {6:+}{5:+}{6:+}{5:>\} dogs | - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*12 | ]]) end) @@ -1557,33 +1552,36 @@ describe('ColorColumn highlight', function() end) end) -describe("MsgSeparator highlight and msgsep fillchar", function() +describe('MsgSeparator highlight and msgsep fillchar', function() local screen before_each(function() clear() - screen = Screen.new(50,5) + screen = Screen.new(50, 5) screen:set_default_attr_ids({ - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {bold=true, reverse=true}, - [3] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [4] = {background = Screen.colors.Cyan, bold = true, reverse = true}, - [5] = {bold = true, background = Screen.colors.Magenta}, - [6] = {background = Screen.colors.WebGray}, - [7] = {background = Screen.colors.WebGray, bold = true, foreground = Screen.colors.SeaGreen4}, - [8] = {foreground = Screen.colors.Grey0, background = Screen.colors.Gray60}, - [9] = {foreground = Screen.colors.Grey40, background = Screen.colors.Gray60}, - [10] = {foreground = tonumber('0x000019'), background = Screen.colors.Gray60}, - [11] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x666699')}, - [12] = {background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e')}, - [13] = {background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff')}, + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true, reverse = true }, + [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [4] = { background = Screen.colors.Cyan, bold = true, reverse = true }, + [5] = { bold = true, background = Screen.colors.Magenta }, + [6] = { background = Screen.colors.WebGray }, + [7] = { + background = Screen.colors.WebGray, + bold = true, + foreground = Screen.colors.SeaGreen4, + }, + [8] = { foreground = Screen.colors.Grey0, background = Screen.colors.Gray60 }, + [9] = { foreground = Screen.colors.Grey40, background = Screen.colors.Gray60 }, + [10] = { foreground = tonumber('0x000019'), background = Screen.colors.Gray60 }, + [11] = { background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x666699') }, + [12] = { background = Screen.colors.Gray60, bold = true, foreground = tonumber('0x297d4e') }, + [13] = { background = tonumber('0xff4cff'), bold = true, foreground = tonumber('0xb200ff') }, }) screen:attach() end) - it("works", function() - + it('works', function() -- defaults - feed_command("ls") + feed_command('ls') screen:expect([[ | {2: }| @@ -1593,8 +1591,8 @@ describe("MsgSeparator highlight and msgsep fillchar", function() ]]) feed('<cr>') - feed_command("set fillchars+=msgsep:-") - feed_command("ls") + feed_command('set fillchars+=msgsep:-') + feed_command('ls') screen:expect([[ | {2:--------------------------------------------------}| @@ -1604,8 +1602,8 @@ describe("MsgSeparator highlight and msgsep fillchar", function() ]]) -- linked to StatusLine per default - feed_command("hi StatusLine guibg=Cyan") - feed_command("ls") + feed_command('hi StatusLine guibg=Cyan') + feed_command('ls') screen:expect([[ | {4:--------------------------------------------------}| @@ -1615,9 +1613,9 @@ describe("MsgSeparator highlight and msgsep fillchar", function() ]]) -- but can be unlinked - feed_command("hi clear MsgSeparator") - feed_command("hi MsgSeparator guibg=Magenta gui=bold") - feed_command("ls") + feed_command('hi clear MsgSeparator') + feed_command('hi MsgSeparator guibg=Magenta gui=bold') + feed_command('ls') screen:expect([[ | {5:--------------------------------------------------}| @@ -1627,169 +1625,63 @@ describe("MsgSeparator highlight and msgsep fillchar", function() ]]) end) - it("and MsgArea", function() - feed_command("hi MsgArea guibg=Gray") - screen:expect{grid=[[ + it('and MsgArea', function() + feed_command('hi MsgArea guibg=Gray') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {6: }| - ]]} - feed(":ls") - screen:expect{grid=[[ + ]], + } + feed(':ls') + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {6::ls^ }| - ]]} - feed(":<cr>") - screen:expect{grid=[[ + ]], + } + feed(':<cr>') + screen:expect { + grid = [[ | {2: }| {6::ls: }| {6: 1 %a "[No Name]" line 1 }| {7:Press ENTER or type command to continue}{6:^ }| - ]]} + ]], + } -- support madness^Wblending of message "overlay" - feed_command("hi MsgArea blend=20") - feed_command("hi clear MsgSeparator") - feed_command("hi MsgSeparator blend=30 guibg=Magenta") - screen:expect{grid=[[ + feed_command('hi MsgArea blend=20') + feed_command('hi clear MsgSeparator') + feed_command('hi MsgSeparator blend=30 guibg=Magenta') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {8::hi}{9: }{8:MsgSeparator}{9: }{8:blend=30}{9: }{8:guibg=Magenta}{9: }| - ]]} - feed(":ls") - screen:expect{grid=[[ + ]], + } + feed(':ls') + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {8::ls}{9:^ }| - ]]} - feed("<cr>") - screen:expect{grid=[[ + ]], + } + feed('<cr>') + screen:expect { + grid = [[ | {13:~ }| {10::ls}{11: }| {11:~ }{10:1}{11: }{10:%a}{11: }{10:"[No}{11: }{10:Name]"}{11: }{10:line}{11: }{10:1}{11: }| {12:Press}{9: }{12:ENTER}{9: }{12:or}{9: }{12:type}{9: }{12:command}{9: }{12:to}{9: }{12:continue}{9:^ }| - ]]} - end) -end) - -describe("'number' and 'relativenumber' highlight", function() - before_each(clear) - - it('LineNr, LineNrAbove and LineNrBelow', function() - local screen = Screen.new(20,10) - screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Red}, - [2] = {foreground = Screen.colors.Blue}, - [3] = {foreground = Screen.colors.Green}, - }) - screen:attach() - command('set number relativenumber') - command('call setline(1, range(50))') - command('highlight LineNr guifg=Red') - feed('4j') - screen:expect([[ - {1: 4 }0 | - {1: 3 }1 | - {1: 2 }2 | - {1: 1 }3 | - {1:5 }^4 | - {1: 1 }5 | - {1: 2 }6 | - {1: 3 }7 | - {1: 4 }8 | - | - ]]) - command('highlight LineNrAbove guifg=Blue') - screen:expect([[ - {2: 4 }0 | - {2: 3 }1 | - {2: 2 }2 | - {2: 1 }3 | - {1:5 }^4 | - {1: 1 }5 | - {1: 2 }6 | - {1: 3 }7 | - {1: 4 }8 | - | - ]]) - command('highlight LineNrBelow guifg=Green') - screen:expect([[ - {2: 4 }0 | - {2: 3 }1 | - {2: 2 }2 | - {2: 1 }3 | - {1:5 }^4 | - {3: 1 }5 | - {3: 2 }6 | - {3: 3 }7 | - {3: 4 }8 | - | - ]]) - feed('3j') - screen:expect([[ - {2: 7 }0 | - {2: 6 }1 | - {2: 5 }2 | - {2: 4 }3 | - {2: 3 }4 | - {2: 2 }5 | - {2: 1 }6 | - {1:8 }^7 | - {3: 1 }8 | - | - ]]) - end) - - -- oldtest: Test_relativenumber_callback() - it('relative number highlight is updated if cursor is moved from timer', function() - local screen = Screen.new(50, 8) - screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Brown}, -- LineNr - [2] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText - }) - screen:attach() - exec([[ - call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd']) - set relativenumber - call cursor(4, 1) - - func Func(timer) - call cursor(1, 1) - endfunc - - call timer_start(300, 'Func') - ]]) - screen:expect({grid = [[ - {1: 3 }aaaaa | - {1: 2 }bbbbb | - {1: 1 }ccccc | - {1: 0 }^ddddd | - {2:~ }| - {2:~ }| - {2:~ }| - | - ]], timeout = 100}) - screen:expect({grid = [[ - {1: 0 }^aaaaa | - {1: 1 }bbbbb | - {1: 2 }ccccc | - {1: 3 }ddddd | - {2:~ }| - {2:~ }| - {2:~ }| - | - ]]}) + ]], + } end) end) @@ -1798,54 +1690,57 @@ describe("'winhighlight' highlight", function() before_each(function() clear() - screen = Screen.new(20,8) + screen = Screen.new(20, 8) screen:attach() screen:set_default_attr_ids { - [0] = {bold=true, foreground=Screen.colors.Blue}; - [1] = {background = Screen.colors.DarkBlue}; - [2] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Blue1}; - [3] = {bold = true, reverse = true}; - [4] = {reverse = true}; - [5] = {background = Screen.colors.DarkGreen}; - [6] = {background = Screen.colors.DarkGreen, bold = true, foreground = Screen.colors.Blue1}; - [7] = {background = Screen.colors.DarkMagenta}; - [8] = {background = Screen.colors.DarkMagenta, bold = true, foreground = Screen.colors.Blue1}; - [9] = {foreground = Screen.colors.Brown}; - [10] = {foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue}; - [11] = {background = Screen.colors.DarkBlue, bold = true, reverse = true}; - [12] = {background = Screen.colors.DarkGreen, reverse = true}; - [13] = {background = Screen.colors.Magenta4, reverse = true}; - [14] = {background = Screen.colors.DarkBlue, reverse = true}; - [15] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; - [16] = {foreground = Screen.colors.Blue1}; - [17] = {background = Screen.colors.LightRed}; - [18] = {background = Screen.colors.Gray90}; - [19] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}; - [20] = {background = Screen.colors.LightGrey, underline = true}; - [21] = {bold = true}; - [22] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [23] = {background = Screen.colors.LightMagenta}; - [24] = {background = Screen.colors.WebGray}; - [25] = {bold = true, foreground = Screen.colors.Green1}; - [26] = {background = Screen.colors.Red}; - [27] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1}; - [28] = {bold = true, foreground = Screen.colors.Brown}; - [29] = {foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true}; - [30] = {background = tonumber('0xff8800')}; - [31] = {background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue}; + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.DarkBlue }, + [2] = { background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Blue1 }, + [3] = { bold = true, reverse = true }, + [4] = { reverse = true }, + [5] = { background = Screen.colors.DarkGreen }, + [6] = { background = Screen.colors.DarkGreen, bold = true, foreground = Screen.colors.Blue1 }, + [7] = { background = Screen.colors.DarkMagenta }, + [8] = { + background = Screen.colors.DarkMagenta, + bold = true, + foreground = Screen.colors.Blue1, + }, + [9] = { foreground = Screen.colors.Brown }, + [10] = { foreground = Screen.colors.Brown, background = Screen.colors.DarkBlue }, + [11] = { background = Screen.colors.DarkBlue, bold = true, reverse = true }, + [12] = { background = Screen.colors.DarkGreen, reverse = true }, + [13] = { background = Screen.colors.Magenta4, reverse = true }, + [14] = { background = Screen.colors.DarkBlue, reverse = true }, + [15] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [16] = { foreground = Screen.colors.Blue1 }, + [17] = { background = Screen.colors.LightRed }, + [18] = { background = Screen.colors.Gray90 }, + [19] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + [20] = { background = Screen.colors.LightGrey, underline = true }, + [21] = { bold = true }, + [22] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [23] = { background = Screen.colors.LightMagenta }, + [24] = { background = Screen.colors.WebGray }, + [25] = { bold = true, foreground = Screen.colors.Green1 }, + [26] = { background = Screen.colors.Red }, + [27] = { background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1 }, + [28] = { bold = true, foreground = Screen.colors.Brown }, + [29] = { foreground = Screen.colors.Blue1, background = Screen.colors.Red, bold = true }, + [30] = { background = tonumber('0xff8800') }, + [31] = { background = tonumber('0xff8800'), bold = true, foreground = Screen.colors.Blue }, } - command("hi Background1 guibg=DarkBlue") - command("hi Background2 guibg=DarkGreen") + command('hi Background1 guibg=DarkBlue') + command('hi Background2 guibg=DarkGreen') end) it('works for background color', function() - insert("aa") - command("split") - command("set winhl=Normal:Background1") + insert('aa') + command('split') + command('set winhl=Normal:Background1') screen:expect([[ {1:a^a }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] [+] }| aa | {0:~ }| @@ -1853,11 +1748,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("enew") + command('enew') screen:expect([[ {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] }| aa | {0:~ }| @@ -1874,84 +1768,64 @@ describe("'winhighlight' highlight", function() command('setlocal winhl=Normal:Background1') screen:expect([[ {1: ^aa}| - {2: ~}| - {2: ~}| - {2: ~}| - {2: ~}| + {2: ~}|*4 | ]]) command('botright vsplit') screen:expect([[ {1: aa│ ^aa}| - {2: ~}{1:│}{2: ~}| - {2: ~}{1:│}{2: ~}| - {2: ~}{1:│}{2: ~}| + {2: ~}{1:│}{2: ~}|*3 {4:[No Name] [+] }{3:[No Name] [+] }| | ]]) end) it('handles undefined groups', function() - command("set winhl=Normal:Background1") + command('set winhl=Normal:Background1') screen:expect([[ {1:^ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*6 | ]]) - command("set winhl=xxx:yyy") + command('set winhl=xxx:yyy') eq('xxx:yyy', eval('&winhl')) - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | - ]]} + ]], + } end) it('can be changed to define different groups', function() - command("set winhl=EndOfBuffer:Background1") - screen:expect{grid=[[ + command('set winhl=EndOfBuffer:Background1') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | - ]]} + ]], + } - command("set winhl=Normal:ErrorMsg") - screen:expect{grid=[[ + command('set winhl=Normal:ErrorMsg') + screen:expect { + grid = [[ {15:^ }| - {29:~ }| - {29:~ }| - {29:~ }| - {29:~ }| - {29:~ }| - {29:~ }| + {29:~ }|*6 | - ]]} + ]], + } end) it('works local to the window', function() - insert("aa") - command("split") - command("setlocal winhl=Normal:Background1") + insert('aa') + command('split') + command('setlocal winhl=Normal:Background1') screen:expect([[ {1:a^a }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] [+] }| aa | {0:~ }| @@ -1959,11 +1833,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("enew") + command('enew') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| aa | {0:~ }| @@ -1971,11 +1844,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("bnext") + command('bnext') screen:expect([[ {1:^aa }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] [+] }| aa | {0:~ }| @@ -1985,13 +1857,12 @@ describe("'winhighlight' highlight", function() end) it('for inactive window background works', function() - command("set winhl=Normal:Background1,NormalNC:Background2") + command('set winhl=Normal:Background1,NormalNC:Background2') -- tests global value is copied across split - command("split") + command('split') screen:expect([[ {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] }| {5: }| {6:~ }| @@ -1999,11 +1870,10 @@ describe("'winhighlight' highlight", function() | ]]) - feed("<c-w><c-w>") + feed('<c-w><c-w>') screen:expect([[ {5: }| - {6:~ }| - {6:~ }| + {6:~ }|*2 {4:[No Name] }| {1:^ }| {2:~ }| @@ -2011,11 +1881,10 @@ describe("'winhighlight' highlight", function() | ]]) - feed("<c-w><c-w>") + feed('<c-w><c-w>') screen:expect([[ {1:^ }| - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] }| {5: }| {6:~ }| @@ -2025,13 +1894,12 @@ describe("'winhighlight' highlight", function() end) it('works with NormalNC', function() - command("hi NormalNC guibg=DarkMagenta") + command('hi NormalNC guibg=DarkMagenta') -- tests global value is copied across split - command("split") + command('split') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| {7: }| {8:~ }| @@ -2039,11 +1907,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("wincmd w") + command('wincmd w') screen:expect([[ {7: }| - {8:~ }| - {8:~ }| + {8:~ }|*2 {4:[No Name] }| ^ | {0:~ }| @@ -2051,13 +1918,11 @@ describe("'winhighlight' highlight", function() | ]]) - -- winbg=Normal:... overrides global NormalNC - command("set winhl=Normal:Background1") + command('set winhl=Normal:Background1') screen:expect([[ {7: }| - {8:~ }| - {8:~ }| + {8:~ }|*2 {4:[No Name] }| {1:^ }| {2:~ }| @@ -2065,11 +1930,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("wincmd w") + command('wincmd w') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| {1: }| {2:~ }| @@ -2077,12 +1941,11 @@ describe("'winhighlight' highlight", function() | ]]) - command("wincmd w") - command("set winhl=Normal:Background1,NormalNC:Background2") + command('wincmd w') + command('set winhl=Normal:Background1,NormalNC:Background2') screen:expect([[ {7: }| - {8:~ }| - {8:~ }| + {8:~ }|*2 {4:[No Name] }| {1:^ }| {2:~ }| @@ -2090,11 +1953,10 @@ describe("'winhighlight' highlight", function() | ]]) - command("wincmd w") + command('wincmd w') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| {5: }| {6:~ }| @@ -2104,30 +1966,32 @@ describe("'winhighlight' highlight", function() end) it('updates background to changed linked group', function() - command("split") - command("setlocal winhl=Normal:FancyGroup") -- does not yet exist - screen:expect{grid=[[ + command('split') + command('setlocal winhl=Normal:FancyGroup') -- does not yet exist + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | {0:~ }| {4:[No Name] }| | - ]]} + ]], + } - command("hi FancyGroup guibg=#FF8800") -- nice orange - screen:expect{grid=[[ + command('hi FancyGroup guibg=#FF8800') -- nice orange + screen:expect { + grid = [[ {30:^ }| - {31:~ }| - {31:~ }| + {31:~ }|*2 {3:[No Name] }| | {0:~ }| {4:[No Name] }| | - ]]} + ]], + } end) it('background applies also to non-text', function() @@ -2144,10 +2008,7 @@ describe("'winhighlight' highlight", function() {9: 1 } ^Lorem ipsum do| {9: } {0:↪}lor sit | {9: } {0:↪}amet{0:-} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) @@ -2156,10 +2017,7 @@ describe("'winhighlight' highlight", function() {10: 1 }{1: ^Lorem ipsum do}| {10: }{1: }{2:↪}{1:lor sit }| {10: }{1: }{2:↪}{1:amet}{2:-}{1: }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*4 | ]]) @@ -2168,12 +2026,7 @@ describe("'winhighlight' highlight", function() feed('3w') screen:expect([[ {10: 1 }{2:❮}{1: dolor ^sit ame}{2:❯}| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*6 | ]]) end) @@ -2188,11 +2041,7 @@ describe("'winhighlight' highlight", function() screen:expect([[ {25:the} {26:foobar} was {26:fooba}| {26:^r} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) @@ -2202,28 +2051,22 @@ describe("'winhighlight' highlight", function() screen:expect([[ {27:the}{1: }{26:foobar}{1: was }{26:fooba}| {26:^r}{1: }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*5 | ]]) end) it('can override NonText, Conceal and EndOfBuffer', function() - curbufmeths.set_lines(0,-1,true, {"raa\000"}) + api.nvim_buf_set_lines(0, 0, -1, true, { 'raa\000' }) command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})') command('set cole=2 cocu=nvic') command('split') command('call matchaddpos("Conceal", [[1,2]], 0, -1, {"conceal": "#"})') - command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,' - ..'Conceal:Background2') + command('set winhl=SpecialKey:ErrorMsg,EndOfBuffer:Background1,' .. 'Conceal:Background2') screen:expect([[ ^r{5:#}a{15:^@} | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[No Name] [+] }| r{19:#}a{16:^@} | {0:~ }| @@ -2240,8 +2083,7 @@ describe("'winhighlight' highlight", function() feed('k') command('split') - command('set winhl=LineNr:Background1,CursorColumn:Background2,' - ..'ColorColumn:ErrorMsg') + command('set winhl=LineNr:Background1,CursorColumn:Background2,' .. 'ColorColumn:ErrorMsg') screen:expect([[ {1: 1 }v{15:e}ry tex^t | {1: 2 }m{15:o}re tex{5:t} | @@ -2261,22 +2103,14 @@ describe("'winhighlight' highlight", function() screen:expect([[ {20: No Name] }{15: No Name]}{20:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) - command("tabnext") + command('tabnext') screen:expect([[ {21: No Name] }{1: No Name]}{20:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) end) @@ -2284,12 +2118,12 @@ describe("'winhighlight' highlight", function() it('can override popupmenu', function() insert('word wording wordy') command('split') - command('set winhl=Pmenu:Background1,PmenuSel:Background2,' - ..'PmenuSbar:ErrorMsg,PmenuThumb:Normal') + command( + 'set winhl=Pmenu:Background1,PmenuSel:Background2,' .. 'PmenuSbar:ErrorMsg,PmenuThumb:Normal' + ) screen:expect([[ word wording word^y | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] [+] }| word wording wordy | {0:~ }| @@ -2327,40 +2161,43 @@ describe("'winhighlight' highlight", function() command('set cursorline number') command('split') command('set winhl=CursorLine:Background1') - screen:expect{grid=[[ + screen:expect { + grid = [[ {28: 1 }{1:^ }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| {28: 1 }{18: }| {0:~ }| {4:[No Name] }| | - ]]} + ]], + } command('set winhl=CursorLineNr:Background2,CursorLine:Background1') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: 1 }{1:^ }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| {28: 1 }{18: }| {0:~ }| {4:[No Name] }| | - ]]} + ]], + } feed('<c-w>w') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: 1 }{1: }| - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:[No Name] }| {28: 1 }{18:^ }| {0:~ }| {3:[No Name] }| | - ]]} + ]], + } end) it('can override StatusLine and StatusLineNC', function() @@ -2368,8 +2205,7 @@ describe("'winhighlight' highlight", function() command('split') screen:expect([[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {1:[No Name] }| | {0:~ }| @@ -2394,8 +2230,7 @@ describe("'winhighlight' highlight", function() ]]) end) - - it("can override syntax groups", function() + it('can override syntax groups', function() command('syntax on') command('syntax keyword Foobar foobar') command('syntax keyword Article the') @@ -2405,17 +2240,14 @@ describe("'winhighlight' highlight", function() screen:expect([[ {25:the} {26:foobar} was {26:fooba}| {26:^r} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | ]]) command('split') command('set winhl=Foobar:Background1,Article:ErrorMsg') - screen:expect{grid=[[ + screen:expect { + grid = [[ {15:the} {1:foobar} was {1:fooba}| {1:^r} | {0:~ }| @@ -2424,21 +2256,23 @@ describe("'winhighlight' highlight", function() {26:r} | {4:[No Name] [+] }| | - ]]} + ]], + } end) it('can be disabled in newly opened window #19823', function() command('split | set winhl=Normal:ErrorMsg | set winhl=') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | {0:~ }| {4:[No Name] }| | - ]]} + ]], + } helpers.assert_alive() end) @@ -2452,7 +2286,8 @@ describe("'winhighlight' highlight", function() insert [[ some text more text]] - screen:expect{grid=[[ + screen:expect { + grid = [[ some text | more tex^t | {0:~ }| @@ -2461,10 +2296,12 @@ describe("'winhighlight' highlight", function() more text | {4:[No Name] }{1:1,1 All}| | - ]]} + ]], + } command 'set winhl=Background1:Background2' - screen:expect{grid=[[ + screen:expect { + grid = [[ some text | more tex^t | {0:~ }| @@ -2473,10 +2310,12 @@ describe("'winhighlight' highlight", function() more text | {4:[No Name] }{1:1,1 All}| | - ]]} + ]], + } feed 'k' - screen:expect{grid=[[ + screen:expect { + grid = [[ some tex^t | more text | {0:~ }| @@ -2485,7 +2324,8 @@ describe("'winhighlight' highlight", function() more text | {4:[No Name] }{1:1,1 All}| | - ]]} + ]], + } end) it('can link to empty highlight group', function() @@ -2493,16 +2333,17 @@ describe("'winhighlight' highlight", function() command 'set winhl=NormalNC:Normal' command 'split' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | {0:~ }| {4:[No Name] }| | - ]]} + ]], + } end) end) @@ -2512,97 +2353,82 @@ describe('highlight namespaces', function() before_each(function() clear() - screen = Screen.new(25,10) + screen = Screen.new(25, 10) screen:attach() screen:set_default_attr_ids { - [1] = {foreground = Screen.colors.Blue, bold = true}; - [2] = {background = Screen.colors.DarkGrey}; - [3] = {italic = true, foreground = Screen.colors.DarkCyan, background = Screen.colors.DarkOrange4}; - [4] = {background = Screen.colors.Magenta4}; - [5] = {background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson}; - [6] = {bold = true, reverse = true}; - [7] = {reverse = true}; - [8] = {foreground = Screen.colors.Gray20}; - [9] = {foreground = Screen.colors.Blue}; - [10] = {bold = true, foreground = Screen.colors.SeaGreen}; + [1] = { foreground = Screen.colors.Blue, bold = true }, + [2] = { background = Screen.colors.DarkGrey }, + [3] = { + italic = true, + foreground = Screen.colors.DarkCyan, + background = Screen.colors.DarkOrange4, + }, + [4] = { background = Screen.colors.Magenta4 }, + [5] = { background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson }, + [6] = { bold = true, reverse = true }, + [7] = { reverse = true }, + [8] = { foreground = Screen.colors.Gray20 }, + [9] = { foreground = Screen.colors.Blue }, + [10] = { bold = true, foreground = Screen.colors.SeaGreen }, } - ns1 = meths.create_namespace 'grungy' - ns2 = meths.create_namespace 'ultrared' + ns1 = api.nvim_create_namespace 'grungy' + ns2 = api.nvim_create_namespace 'ultrared' - meths.set_hl(ns1, 'Normal', {bg='DarkGrey'}) - meths.set_hl(ns1, 'NonText', {bg='DarkOrange4', fg='DarkCyan', italic=true}) - meths.set_hl(ns2, 'Normal', {bg='DarkMagenta'}) - meths.set_hl(ns2, 'NonText', {fg='Crimson'}) + api.nvim_set_hl(ns1, 'Normal', { bg = 'DarkGrey' }) + api.nvim_set_hl(ns1, 'NonText', { bg = 'DarkOrange4', fg = 'DarkCyan', italic = true }) + api.nvim_set_hl(ns2, 'Normal', { bg = 'DarkMagenta' }) + api.nvim_set_hl(ns2, 'NonText', { fg = 'Crimson' }) end) it('can be used globally', function() - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | - ]]} + ]], + } - meths.set_hl_ns(ns1) - screen:expect{grid=[[ + api.nvim_set_hl_ns(ns1) + screen:expect { + grid = [[ {2:^ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*8 | - ]]} + ]], + } - meths.set_hl_ns(ns2) - screen:expect{grid=[[ + api.nvim_set_hl_ns(ns2) + screen:expect { + grid = [[ {4:^ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*8 | - ]]} + ]], + } - meths.set_hl_ns(0) - screen:expect{grid=[[ + api.nvim_set_hl_ns(0) + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | - ]]} + ]], + } end) it('can be used per window', function() - local win1 = meths.get_current_win() + local win1 = api.nvim_get_current_win() command 'split' - local win2 = meths.get_current_win() + local win2 = api.nvim_get_current_win() command 'split' - meths.win_set_hl_ns(win1, ns1) - meths.win_set_hl_ns(win2, ns2) + api.nvim_win_set_hl_ns(win1, ns1) + api.nvim_win_set_hl_ns(win2, ns2) - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }| {6:[No Name] }| @@ -2613,36 +2439,27 @@ describe('highlight namespaces', function() {3:~ }| {7:[No Name] }| | - ]]} + ]], + } end) it('redraws correctly when ns=0', function() - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | - ]]} + ]], + } - meths.set_hl(0, 'EndOfBuffer', {fg='#333333'}) - screen:expect{grid=[[ + api.nvim_set_hl(0, 'EndOfBuffer', { fg = '#333333' }) + screen:expect { + grid = [[ ^ | - {8:~ }| - {8:~ }| - {8:~ }| - {8:~ }| - {8:~ }| - {8:~ }| - {8:~ }| - {8:~ }| + {8:~ }|*8 | - ]]} + ]], + } end) it('winhl does not accept invalid value #24586', function() @@ -2653,18 +2470,19 @@ describe('highlight namespaces', function() return { msg, vim.wo[curwin].winhl } ]]) eq({ - "Vim(set):E5248: Invalid character in group name", - "Normal:Visual", - },res) + 'Vim(set):E5248: Invalid character in group name', + 'Normal:Visual', + }, res) end) it('Normal in set_hl #25474', function() - meths.set_hl(0, 'Normal', {bg='#333333'}) + command('highlight Ignore guifg=bg ctermfg=White') + api.nvim_set_hl(0, 'Normal', { bg = '#333333' }) command('highlight Ignore') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {6: }| | Ignore {8:xxx} {9:ctermf}| @@ -2672,6 +2490,7 @@ describe('highlight namespaces', function() bg | {10:Press ENTER or type comma}| {10:nd to continue}^ | - ]]} + ]], + } end) end) diff --git a/test/functional/ui/hlstate_spec.lua b/test/functional/ui/hlstate_spec.lua index 55f873e827..8b36ad5431 100644 --- a/test/functional/ui/hlstate_spec.lua +++ b/test/functional/ui/hlstate_spec.lua @@ -3,7 +3,7 @@ local Screen = require('test.functional.ui.screen') local clear, insert = helpers.clear, helpers.insert local command = helpers.command -local meths = helpers.meths +local api = helpers.api local testprg = helpers.testprg local thelpers = require('test.functional.terminal.helpers') local skip = helpers.skip @@ -17,127 +17,157 @@ describe('ext_hlstate detailed highlights', function() command('syntax on') command('hi VertSplit gui=reverse') screen = Screen.new(40, 8) - screen:attach({ext_hlstate=true}) + screen:attach({ ext_hlstate = true }) end) after_each(function() screen:detach() end) - it('work with combined UI and syntax highlights', function() insert([[ these are some lines with colorful text]]) - meths.buf_add_highlight(0, -1, "String", 0 , 10, 14) - meths.buf_add_highlight(0, -1, "Statement", 1 , 5, -1) - command("/th co") + api.nvim_buf_add_highlight(0, -1, 'String', 0, 10, 14) + api.nvim_buf_add_highlight(0, -1, 'Statement', 1, 5, -1) + command('/th co') - screen:expect([[ + screen:expect( + [[ these are {1:some} lines | ^wi{2:th }{4:co}{3:lorful text} | - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| - {5:~ }| + {5:~ }|*5 {8:search hit BOTTOM, continuing at TOP}{7: }| - ]], { - [1] = {{foreground = Screen.colors.Magenta}, - {{hi_name = "Constant", kind = "syntax"}}}, - [2] = {{background = Screen.colors.Yellow}, - {{hi_name = "Search", ui_name = "Search", kind = "ui"}}}, - [3] = {{bold = true, foreground = Screen.colors.Brown}, - {{hi_name = "Statement", kind = "syntax"}}}, - [4] = {{bold = true, background = Screen.colors.Yellow, foreground = Screen.colors.Brown}, {3, 2}}, - [5] = {{bold = true, foreground = Screen.colors.Blue1}, - {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}}, - [6] = {{foreground = Screen.colors.Red}, - {{hi_name = "WarningMsg", ui_name = "WarningMsg", kind = "ui"}}}, - [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, - [8] = {{foreground = Screen.colors.Red}, {7, 6}}, - }) + ]], + { + [1] = { + { foreground = Screen.colors.Magenta }, + { { hi_name = 'Constant', kind = 'syntax' } }, + }, + [2] = { + { background = Screen.colors.Yellow }, + { { hi_name = 'Search', ui_name = 'Search', kind = 'ui' } }, + }, + [3] = { + { bold = true, foreground = Screen.colors.Brown }, + { { hi_name = 'Statement', kind = 'syntax' } }, + }, + [4] = { + { bold = true, background = Screen.colors.Yellow, foreground = Screen.colors.Brown }, + { 3, 2 }, + }, + [5] = { + { bold = true, foreground = Screen.colors.Blue1 }, + { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } }, + }, + [6] = { + { foreground = Screen.colors.Red }, + { { hi_name = 'WarningMsg', ui_name = 'WarningMsg', kind = 'ui' } }, + }, + [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } }, + [8] = { { foreground = Screen.colors.Red }, { 7, 6 } }, + } + ) end) it('work with cleared UI highlights', function() screen:set_default_attr_ids({ - [1] = {{}, {{hi_name = "Normal", ui_name = "WinSeparator", kind = "ui"}}}, - [2] = {{bold = true, foreground = Screen.colors.Blue1}, - {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}}, - [3] = {{bold = true, reverse = true}, - {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}} , - [4] = {{reverse = true}, - {{hi_name = "StatusLineNC", ui_name = "StatusLineNC" , kind = "ui"}}}, - [5] = {{}, {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}}, - [6] = {{}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}}, - [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, + [1] = { {}, { { hi_name = 'Normal', ui_name = 'WinSeparator', kind = 'ui' } } }, + [2] = { + { bold = true, foreground = Screen.colors.Blue1 }, + { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } }, + }, + [3] = { + { bold = true, reverse = true }, + { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } }, + }, + [4] = { + { reverse = true }, + { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } }, + }, + [5] = { {}, { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } } }, + [6] = { {}, { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } } }, + [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } }, }) - command("hi clear VertSplit") - command("vsplit") + command('hi clear WinSeparator') + command('vsplit') screen:expect([[ ^ {1:│} | - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| + {2:~ }{1:│}{2:~ }|*5 {3:[No Name] }{4:[No Name] }| {7: }| ]]) - command("hi clear StatusLine | hi clear StatuslineNC") + command('hi clear StatusLine | hi clear StatuslineNC') screen:expect([[ ^ {1:│} | - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| + {2:~ }{1:│}{2:~ }|*5 {5:[No Name] }{6:[No Name] }| {7: }| ]]) -- redrawing is done even if visible highlights didn't change - command("wincmd w") + command('wincmd w') screen:expect([[ {1:│}^ | - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| - {2:~ }{1:│}{2:~ }| + {2:~ }{1:│}{2:~ }|*5 {6:[No Name] }{5:[No Name] }| {7: }| ]]) - end) - it("work with window-local highlights", function() + it('work with window-local highlights', function() screen:set_default_attr_ids({ - [1] = {{foreground = Screen.colors.Brown}, {{hi_name = "LineNr", ui_name = "LineNr", kind = "ui"}}}, - [2] = {{bold = true, foreground = Screen.colors.Blue1}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}}, - [3] = {{bold = true, reverse = true}, {{hi_name = "StatusLine", ui_name = "StatusLine", kind = "ui"}}}, - [4] = {{reverse = true}, {{hi_name = "StatusLineNC", ui_name = "StatusLineNC", kind = "ui"}}}, - [5] = {{background = Screen.colors.Red, foreground = Screen.colors.Grey100}, {{hi_name = "ErrorMsg", ui_name = "LineNr", kind = "ui"}}}, - [6] = {{bold = true, reverse = true}, {{hi_name = "Normal", ui_name = "Normal", kind = "ui"}}}, - [7] = {{foreground = Screen.colors.Brown, bold = true, reverse = true}, {6, 1}}, - [8] = {{foreground = Screen.colors.Blue1, bold = true, reverse = true}, {6, 14}}, - [9] = {{bold = true, foreground = Screen.colors.Brown}, {{hi_name = "NormalNC", ui_name = "NormalNC", kind = "ui"}}}, - [10] = {{bold = true, foreground = Screen.colors.Brown}, {9, 1}}, - [11] = {{bold = true, foreground = Screen.colors.Blue1}, {9, 14}}, - [12] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, - [13] = {{background = Screen.colors.Red1, foreground = Screen.colors.Gray100}, {{ui_name = "LineNr", kind = "ui", hi_name = "LineNr"}}}; - [14] = {{bold = true, foreground = Screen.colors.Blue}, {{ui_name = "EndOfBuffer", kind = "ui", hi_name = "EndOfBuffer"}}}; + [1] = { + { foreground = Screen.colors.Brown }, + { { hi_name = 'LineNr', ui_name = 'LineNr', kind = 'ui' } }, + }, + [2] = { + { bold = true, foreground = Screen.colors.Blue1 }, + { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } }, + }, + [3] = { + { bold = true, reverse = true }, + { { hi_name = 'StatusLine', ui_name = 'StatusLine', kind = 'ui' } }, + }, + [4] = { + { reverse = true }, + { { hi_name = 'StatusLineNC', ui_name = 'StatusLineNC', kind = 'ui' } }, + }, + [5] = { + { background = Screen.colors.Red, foreground = Screen.colors.Grey100 }, + { { hi_name = 'ErrorMsg', ui_name = 'LineNr', kind = 'ui' } }, + }, + [6] = { + { bold = true, reverse = true }, + { { hi_name = 'Normal', ui_name = 'Normal', kind = 'ui' } }, + }, + [7] = { { foreground = Screen.colors.Brown, bold = true, reverse = true }, { 6, 1 } }, + [8] = { { foreground = Screen.colors.Blue1, bold = true, reverse = true }, { 6, 14 } }, + [9] = { + { bold = true, foreground = Screen.colors.Brown }, + { { hi_name = 'NormalNC', ui_name = 'NormalNC', kind = 'ui' } }, + }, + [10] = { { bold = true, foreground = Screen.colors.Brown }, { 9, 1 } }, + [11] = { { bold = true, foreground = Screen.colors.Blue1 }, { 9, 14 } }, + [12] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } }, + [13] = { + { background = Screen.colors.Red1, foreground = Screen.colors.Gray100 }, + { { ui_name = 'LineNr', kind = 'ui', hi_name = 'LineNr' } }, + }, + [14] = { + { bold = true, foreground = Screen.colors.Blue }, + { { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'EndOfBuffer' } }, + }, }) - command("set number") - command("split") + command('set number') + command('split') -- NormalNC is not applied if not set, to avoid spurious redraws screen:expect([[ {1: 1 }^ | - {2:~ }| - {2:~ }| + {2:~ }|*2 {3:[No Name] }| {1: 1 } | {2:~ }| @@ -145,23 +175,23 @@ describe('ext_hlstate detailed highlights', function() {12: }| ]]) - command("set winhl=LineNr:ErrorMsg") - screen:expect{grid=[[ + command('set winhl=LineNr:ErrorMsg') + screen:expect { + grid = [[ {13: 1 }^ | - {14:~ }| - {14:~ }| + {14:~ }|*2 {3:[No Name] }| {1: 1 } | {2:~ }| {4:[No Name] }| {12: }| - ]]} + ]], + } - command("set winhl=Normal:MsgSeparator,NormalNC:Statement") + command('set winhl=Normal:MsgSeparator,NormalNC:Statement') screen:expect([[ {7: 1 }{6:^ }| - {8:~ }| - {8:~ }| + {8:~ }|*2 {3:[No Name] }| {1: 1 } | {2:~ }| @@ -169,11 +199,10 @@ describe('ext_hlstate detailed highlights', function() {12: }| ]]) - command("wincmd w") + command('wincmd w') screen:expect([[ {10: 1 }{9: }| - {11:~ }| - {11:~ }| + {11:~ }|*2 {4:[No Name] }| {1: 1 }^ | {2:~ }| @@ -182,27 +211,28 @@ describe('ext_hlstate detailed highlights', function() ]]) end) - it("work with :terminal", function() + it('work with :terminal', function() skip(is_os('win')) screen:set_default_attr_ids({ - [1] = {{}, {{hi_name = "TermCursorNC", ui_name = "TermCursorNC", kind = "ui"}}}, - [2] = {{foreground = tonumber('0x00ccff'), fg_indexed=true}, {{kind = "term"}}}, - [3] = {{bold = true, foreground = tonumber('0x00ccff'), fg_indexed=true}, {{kind = "term"}}}, - [4] = {{foreground = tonumber('0x00ccff'), fg_indexed=true}, {2, 1}}, - [5] = {{foreground = tonumber('0x40ffff'), fg_indexed=true}, {{kind = "term"}}}, - [6] = {{foreground = tonumber('0x40ffff'), fg_indexed=true}, {5, 1}}, - [7] = {{}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, + [1] = { {}, { { hi_name = 'TermCursorNC', ui_name = 'TermCursorNC', kind = 'ui' } } }, + [2] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { { kind = 'term' } } }, + [3] = { + { bold = true, foreground = tonumber('0x00ccff'), fg_indexed = true }, + { + { kind = 'term' }, + }, + }, + [4] = { { foreground = tonumber('0x00ccff'), fg_indexed = true }, { 2, 1 } }, + [5] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { { kind = 'term' } } }, + [6] = { { foreground = tonumber('0x40ffff'), fg_indexed = true }, { 5, 1 } }, + [7] = { {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } }, }) command(("enew | call termopen(['%s'])"):format(testprg('tty-test'))) screen:expect([[ ^tty ready | {1: } | - | - | - | - | - | + |*5 {7: }| ]]) @@ -217,10 +247,7 @@ describe('ext_hlstate detailed highlights', function() ^tty ready | x {5:y z} | {1: } | - | - | - | - | + |*4 {7: }| ]]) else @@ -228,72 +255,337 @@ describe('ext_hlstate detailed highlights', function() ^tty ready | x {2:y }{3:z} | {1: } | - | - | - | - | + |*4 {7: }| ]]) end - thelpers.feed_termcode("[A") - thelpers.feed_termcode("[2C") + thelpers.feed_termcode('[A') + thelpers.feed_termcode('[2C') if is_os('win') then screen:expect([[ ^tty ready | x {6:y}{5: z} | - | - | - | - | - | + |*5 {7: }| ]]) else screen:expect([[ ^tty ready | x {4:y}{2: }{3:z} | - | - | - | - | - | + |*5 {7: }| ]]) end end) - it("can use independent cterm and rgb colors", function() + it('can use independent cterm and rgb colors', function() -- tell test module to save all attributes (doesn't change nvim options) screen:set_rgb_cterm(true) screen:set_default_attr_ids({ - [1] = {{bold = true, foreground = Screen.colors.Blue1}, {foreground = 12}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}}, - [2] = {{reverse = true, foreground = Screen.colors.Red}, {foreground = 10, italic=true}, {{hi_name = "NonText", ui_name = "EndOfBuffer", kind = "ui"}}}, - [3] = {{}, {}, {{hi_name = "MsgArea", ui_name = "MsgArea", kind = "ui"}}}, + [1] = { + { bold = true, foreground = Screen.colors.Blue1 }, + { foreground = 12 }, + { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } }, + }, + [2] = { + { reverse = true, foreground = Screen.colors.Red }, + { foreground = 10, italic = true }, + { { hi_name = 'NonText', ui_name = 'EndOfBuffer', kind = 'ui' } }, + }, + [3] = { {}, {}, { { hi_name = 'MsgArea', ui_name = 'MsgArea', kind = 'ui' } } }, }) screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {3: }| ]]) - command("hi NonText guifg=Red gui=reverse ctermfg=Green cterm=italic") + command('hi NonText guifg=Red gui=reverse ctermfg=Green cterm=italic') screen:expect([[ ^ | + {2:~ }|*6 + {3: }| + ]]) + end) + + it('combines deleted extmark highlights', function() + insert([[ + line1 + line2 + line3 + line4 + line5 + line6]]) + + screen:expect { + grid = [[ + line1 | + line2 | + line3 | + line4 | + line5 | + line^6 | + {1:~ }| + {2: }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.Blue, bold = true }, + { { ui_name = 'EndOfBuffer', hi_name = 'NonText', kind = 'ui' } }, + }, + [2] = { {}, { { ui_name = 'MsgArea', hi_name = 'MsgArea', kind = 'ui' } } }, + }, + } + + local ns = api.nvim_create_namespace('test') + + local add_indicator = function(line, col) + api.nvim_buf_set_extmark(0, ns, line, col, { + hl_mode = 'combine', + priority = 2, + right_gravity = false, + virt_text = { { '|', 'Delimiter' } }, + virt_text_win_col = 0, + virt_text_pos = 'overlay', + }) + end + + add_indicator(1, 0) + add_indicator(2, 0) + add_indicator(3, 0) + add_indicator(4, 0) + + screen:expect { + grid = [[ + line1 | + {1:|} line2 | + {1:|} line3 | + {1:|} line4 | + {1:|} line5 | + line^6 | {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {3: }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { hi_name = 'Special', kind = 'syntax' } }, + }, + [2] = { + { bold = true, foreground = Screen.colors.Blue }, + { { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'NonText' } }, + }, + [3] = { {}, { { ui_name = 'MsgArea', kind = 'ui', hi_name = 'MsgArea' } } }, + }, + } + + helpers.feed('3ggV2jd') + --screen:redraw_debug() + screen:expect { + grid = [[ + line1 | + {1:|} line2 | + {2:^|}ine6 | + {3:~ }|*4 + {4:3 fewer lines }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { kind = 'syntax', hi_name = 'Special' } }, + }, + [2] = { { foreground = Screen.colors.SlateBlue }, { 1, 1, 1 } }, + [3] = { + { bold = true, foreground = Screen.colors.Blue }, + { { kind = 'ui', ui_name = 'EndOfBuffer', hi_name = 'NonText' } }, + }, + [4] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } }, + }, + } + end) + + it('removes deleted extmark highlights with invalidate', function() + insert([[ + line1 + line2 + line3 + line4 + line5 + line6]]) + + screen:expect { + grid = [[ + line1 | + line2 | + line3 | + line4 | + line5 | + line^6 | + {1:~ }| + {2: }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.Blue, bold = true }, + { { ui_name = 'EndOfBuffer', hi_name = 'NonText', kind = 'ui' } }, + }, + [2] = { {}, { { ui_name = 'MsgArea', hi_name = 'MsgArea', kind = 'ui' } } }, + }, + } + + local ns = api.nvim_create_namespace('test') + + local add_indicator = function(line, col) + api.nvim_buf_set_extmark(0, ns, line, col, { + hl_mode = 'combine', + priority = 2, + right_gravity = false, + virt_text = { { '|', 'Delimiter' } }, + virt_text_win_col = 0, + virt_text_pos = 'overlay', + invalidate = true, + }) + end + + add_indicator(1, 0) + add_indicator(2, 0) + add_indicator(3, 0) + add_indicator(4, 0) + + screen:expect { + grid = [[ + line1 | + {1:|} line2 | + {1:|} line3 | + {1:|} line4 | + {1:|} line5 | + line^6 | {2:~ }| {3: }| - ]]) + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { hi_name = 'Special', kind = 'syntax' } }, + }, + [2] = { + { bold = true, foreground = Screen.colors.Blue }, + { { ui_name = 'EndOfBuffer', kind = 'ui', hi_name = 'NonText' } }, + }, + [3] = { {}, { { ui_name = 'MsgArea', kind = 'ui', hi_name = 'MsgArea' } } }, + }, + } + helpers.feed('3ggV2jd') + --screen:redraw_debug() + screen:expect { + grid = [[ + line1 | + {1:|} line2 | + ^line6 | + {2:~ }|*4 + {3:3 fewer lines }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { kind = 'syntax', hi_name = 'Special' } }, + }, + [2] = { + { foreground = Screen.colors.Blue, bold = true }, + { { kind = 'ui', ui_name = 'EndOfBuffer', hi_name = 'NonText' } }, + }, + [3] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } }, + }, + } + end) + + it('does not hang when combining too many highlights', function() + local num_lines = 500 + insert('first line\n') + for _ = 1, num_lines do + insert([[ + line + ]]) + end + insert('last line') + + helpers.feed('gg') + screen:expect { + grid = [[ + ^first line | + line |*6 + {1: }| + ]], + attr_ids = { + [1] = { {}, { { kind = 'ui', hi_name = 'MsgArea', ui_name = 'MsgArea' } } }, + }, + } + local ns = api.nvim_create_namespace('test') + + local add_indicator = function(line, col) + api.nvim_buf_set_extmark(0, ns, line, col, { + hl_mode = 'combine', + priority = 2, + right_gravity = false, + virt_text = { { '|', 'Delimiter' } }, + virt_text_win_col = 0, + virt_text_pos = 'overlay', + }) + end + + for i = 1, num_lines do + add_indicator(i, 0) + end + + screen:expect { + grid = [[ + ^first line | + {1:|} line |*6 + {2: }| + ]], + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { kind = 'syntax', hi_name = 'Special' } }, + }, + [2] = { {}, { { kind = 'ui', ui_name = 'MsgArea', hi_name = 'MsgArea' } } }, + }, + } + + helpers.feed(string.format('3ggV%ijd', num_lines - 2)) + --screen:redraw_debug(nil, nil, 100000) + + local expected_ids = {} + for i = 1, num_lines - 1 do + expected_ids[i] = 1 + end + screen:expect { + grid = string.format( + [[ + first line | + {1:|} line | + {2:^|}ast line | + {3:~ }|*4 + {4:%-40s}| + ]], + tostring(num_lines - 1) .. ' fewer lines' + ), + attr_ids = { + [1] = { + { foreground = Screen.colors.SlateBlue }, + { { kind = 'syntax', hi_name = 'Special' } }, + }, + [2] = { { foreground = Screen.colors.SlateBlue }, expected_ids }, + [3] = { + { foreground = Screen.colors.Blue, bold = true }, + { { kind = 'ui', hi_name = 'NonText', ui_name = 'EndOfBuffer' } }, + }, + [4] = { {}, { { kind = 'ui', hi_name = 'MsgArea', ui_name = 'MsgArea' } } }, + }, + timeout = 100000, + } end) end) diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 3ee67a710c..29c8c43ca1 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -4,18 +4,17 @@ local clear = helpers.clear local command = helpers.command local eq = helpers.eq local eval = helpers.eval -local feed_command = helpers.feed_command local expect = helpers.expect local feed = helpers.feed local insert = helpers.insert -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local neq = helpers.neq local ok = helpers.ok local retry = helpers.retry local source = helpers.source local poke_eventloop = helpers.poke_eventloop -local nvim = helpers.nvim -local sleep = helpers.sleep +local sleep = vim.uv.sleep local testprg = helpers.testprg local assert_alive = helpers.assert_alive @@ -32,7 +31,7 @@ local multiline_text = [[ 7 8 9 ]] -local multimatch_text = [[ +local multimatch_text = [[ a bdc eae a fgl lzia r x ]] @@ -62,70 +61,70 @@ local long_multiline_text = [[ local function common_setup(screen, inccommand, text) if screen then - command("syntax on") - command("set nohlsearch") - command("hi Substitute guifg=red guibg=yellow") + command('syntax on') + command('set nohlsearch') + command('hi Substitute guifg=red guibg=yellow') screen:attach() screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Fuchsia}, - [2] = {foreground = Screen.colors.Brown, bold = true}, - [3] = {foreground = Screen.colors.SlateBlue}, - [4] = {bold = true, foreground = Screen.colors.SlateBlue}, - [5] = {foreground = Screen.colors.DarkCyan}, - [6] = {bold = true}, - [7] = {underline = true, bold = true, foreground = Screen.colors.SlateBlue}, - [8] = {foreground = Screen.colors.Slateblue, underline = true}, - [9] = {background = Screen.colors.Yellow}, - [10] = {reverse = true}, - [11] = {reverse = true, bold=true}, - [12] = {foreground = Screen.colors.Red, background = Screen.colors.Yellow}, - [13] = {bold = true, foreground = Screen.colors.SeaGreen}, - [14] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - [15] = {bold=true, foreground=Screen.colors.Blue}, - [16] = {background=Screen.colors.Grey90}, -- cursorline - [17] = {foreground = Screen.colors.Blue1}, - vis = {background=Screen.colors.LightGrey} + [1] = { foreground = Screen.colors.Fuchsia }, + [2] = { foreground = Screen.colors.Brown, bold = true }, + [3] = { foreground = Screen.colors.SlateBlue }, + [4] = { bold = true, foreground = Screen.colors.SlateBlue }, + [5] = { foreground = Screen.colors.DarkCyan }, + [6] = { bold = true }, + [7] = { underline = true, bold = true, foreground = Screen.colors.SlateBlue }, + [8] = { foreground = Screen.colors.Slateblue, underline = true }, + [9] = { background = Screen.colors.Yellow }, + [10] = { reverse = true }, + [11] = { reverse = true, bold = true }, + [12] = { foreground = Screen.colors.Red, background = Screen.colors.Yellow }, + [13] = { bold = true, foreground = Screen.colors.SeaGreen }, + [14] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + [15] = { bold = true, foreground = Screen.colors.Blue }, + [16] = { background = Screen.colors.Grey90 }, -- cursorline + [17] = { foreground = Screen.colors.Blue1 }, + vis = { background = Screen.colors.LightGrey }, }) end - command("set inccommand=" .. (inccommand or "")) + command('set inccommand=' .. (inccommand or '')) if text then insert(text) end end -describe(":substitute, inccommand=split interactivity", function() +describe(':substitute, inccommand=split interactivity', function() before_each(function() clear() - common_setup(nil, "split", default_text) + common_setup(nil, 'split', default_text) end) -- Test the tests: verify that the `1==bufnr('$')` assertion -- in the "no preview" tests (below) actually means something. - it("previews interactive cmdline", function() + it('previews interactive cmdline', function() feed(':%s/tw/MO/g') retry(nil, 1000, function() eq(2, eval("bufnr('$')")) end) end) - it("no preview if invoked by a script", function() + it('no preview if invoked by a script', function() source('%s/tw/MO/g') poke_eventloop() eq(1, eval("bufnr('$')")) -- sanity check: assert the buffer state - expect(default_text:gsub("tw", "MO")) + expect(default_text:gsub('tw', 'MO')) end) - it("no preview if invoked by feedkeys()", function() + it('no preview if invoked by feedkeys()', function() -- in a script... source([[:call feedkeys(":%s/tw/MO/g\<CR>")]]) -- or interactively... feed([[:call feedkeys(":%s/bs/BUU/g\<lt>CR>")<CR>]]) eq(1, eval("bufnr('$')")) -- sanity check: assert the buffer state - expect(default_text:gsub("tw", "MO"):gsub("bs", "BUU")) + expect(default_text:gsub('tw', 'MO'):gsub('bs', 'BUU')) end) end) @@ -133,17 +132,17 @@ describe(":substitute, 'inccommand' preserves", function() before_each(clear) it('listed buffers (:ls)', function() - local screen = Screen.new(30,10) - common_setup(screen, "split", "ABC") + local screen = Screen.new(30, 10) + common_setup(screen, 'split', 'ABC') - feed_command("%s/AB/BA/") - feed_command("ls") + feed(':%s/AB/BA/') + poke_eventloop() + feed('<CR>') + feed(':ls<CR>') screen:expect([[ BAC | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {11: }| :ls | 1 %a + "[No Name]" | @@ -153,43 +152,68 @@ describe(":substitute, 'inccommand' preserves", function() ]]) end) - for _, case in pairs{"", "split", "nosplit"} do - it("various delimiters (inccommand="..case..")", function() + it("'[ and '] marks #26439", function() + local screen = Screen.new(30, 10) + common_setup(screen, 'nosplit', ('abc\ndef\n'):rep(50)) + + feed('ggyG') + local X = api.nvim_get_vvar('maxcol') + eq({ 0, 1, 1, 0 }, fn.getpos("'[")) + eq({ 0, 101, X, 0 }, fn.getpos("']")) + + feed(":'[,']s/def/") + poke_eventloop() + eq({ 0, 1, 1, 0 }, fn.getpos("'[")) + eq({ 0, 101, X, 0 }, fn.getpos("']")) + + feed('DEF/g') + poke_eventloop() + eq({ 0, 1, 1, 0 }, fn.getpos("'[")) + eq({ 0, 101, X, 0 }, fn.getpos("']")) + + feed('<CR>') + expect(('abc\nDEF\n'):rep(50)) + end) + + for _, case in pairs { '', 'split', 'nosplit' } do + it('various delimiters (inccommand=' .. case .. ')', function() insert(default_text) - feed_command("set inccommand=" .. case) + command('set inccommand=' .. case) local delims = { '/', '#', ';', '%', ',', '@', '!' } - for _,delim in pairs(delims) do - feed_command("%s"..delim.."lines"..delim.."LINES"..delim.."g") + for _, delim in pairs(delims) do + feed(':%s' .. delim .. 'lines' .. delim .. 'LINES' .. delim .. 'g') + poke_eventloop() + feed('<CR>') expect([[ Inc substitution on two LINES ]]) - feed_command("undo") + command('undo') end end) end - for _, case in pairs{"", "split", "nosplit"} do - it("'undolevels' (inccommand="..case..")", function() - feed_command("set undolevels=139") - feed_command("setlocal undolevels=34") - feed_command("split") -- Show the buffer in multiple windows - feed_command("set inccommand=" .. case) - insert("as") - feed(":%s/as/glork/") + for _, case in pairs { '', 'split', 'nosplit' } do + it("'undolevels' (inccommand=" .. case .. ')', function() + command('set undolevels=139') + command('setlocal undolevels=34') + command('split') -- Show the buffer in multiple windows + command('set inccommand=' .. case) + insert('as') + feed(':%s/as/glork/') poke_eventloop() - feed("<enter>") - eq(meths.get_option_value('undolevels', {scope='global'}), 139) - eq(meths.get_option_value('undolevels', {buf=0}), 34) + feed('<enter>') + eq(api.nvim_get_option_value('undolevels', { scope = 'global' }), 139) + eq(api.nvim_get_option_value('undolevels', { buf = 0 }), 34) end) end - for _, case in ipairs({"", "split", "nosplit"}) do - it("empty undotree() (inccommand="..case..")", function() - feed_command("set undolevels=1000") - feed_command("set inccommand=" .. case) - local expected_undotree = eval("undotree()") + for _, case in ipairs({ '', 'split', 'nosplit' }) do + it('empty undotree() (inccommand=' .. case .. ')', function() + command('set undolevels=1000') + command('set inccommand=' .. case) + local expected_undotree = eval('undotree()') -- Start typing an incomplete :substitute command. feed([[:%s/e/YYYY/g]]) @@ -198,15 +222,15 @@ describe(":substitute, 'inccommand' preserves", function() feed([[<C-\><C-N>]]) -- The undo tree should be unchanged. - eq(expected_undotree, eval("undotree()")) - eq({}, eval("undotree()")["entries"]) + eq(expected_undotree, eval('undotree()')) + eq({}, eval('undotree()')['entries']) end) end - for _, case in ipairs({"", "split", "nosplit"}) do - it("undotree() with branches (inccommand="..case..")", function() - feed_command("set undolevels=1000") - feed_command("set inccommand=" .. case) + for _, case in ipairs({ '', 'split', 'nosplit' }) do + it('undotree() with branches (inccommand=' .. case .. ')', function() + command('set undolevels=1000') + command('set inccommand=' .. case) -- Make some changes. feed([[isome text 1<C-\><C-N>]]) feed([[osome text 2<C-\><C-N>]]) @@ -224,8 +248,8 @@ describe(":substitute, 'inccommand' preserves", function() some text 1 some text 3XX some text 5]]) - local expected_undotree = eval("undotree()") - eq(5, #expected_undotree["entries"]) -- sanity + local expected_undotree = eval('undotree()') + eq(5, #expected_undotree['entries']) -- sanity -- Start typing an incomplete :substitute command. feed([[:%s/e/YYYY/g]]) @@ -234,31 +258,31 @@ describe(":substitute, 'inccommand' preserves", function() feed([[<C-\><C-N>]]) -- The undo tree should be unchanged. - eq(expected_undotree, eval("undotree()")) + eq(expected_undotree, eval('undotree()')) end) end - for _, case in pairs{"", "split", "nosplit"} do - it("b:changedtick (inccommand="..case..")", function() - feed_command("set inccommand=" .. case) + for _, case in pairs { '', 'split', 'nosplit' } do + it('b:changedtick (inccommand=' .. case .. ')', function() + command('set inccommand=' .. case) feed([[isome text 1<C-\><C-N>]]) feed([[osome text 2<C-\><C-N>]]) - local expected_tick = eval("b:changedtick") + local expected_tick = eval('b:changedtick') ok(expected_tick > 0) expect([[ some text 1 some text 2]]) - feed(":%s/e/XXX/") + feed(':%s/e/XXX/') poke_eventloop() - eq(expected_tick, eval("b:changedtick")) + eq(expected_tick, eval('b:changedtick')) end) end - for _, case in ipairs({'', 'split', 'nosplit'}) do - it('previous substitute string ~ (inccommand='..case..') #12109', function() - local screen = Screen.new(30,10) + for _, case in ipairs({ '', 'split', 'nosplit' }) do + it('previous substitute string ~ (inccommand=' .. case .. ') #12109', function() + local screen = Screen.new(30, 10) common_setup(screen, case, default_text) feed(':%s/Inc/SUB<CR>') @@ -323,47 +347,51 @@ describe(":substitute, 'inccommand' preserves", function() end) describe(":substitute, 'inccommand' preserves undo", function() - local cases = { "", "split", "nosplit" } + local cases = { '', 'split', 'nosplit' } local substrings = { - ":%s/1", - ":%s/1/", - ":%s/1/<bs>", - ":%s/1/a", - ":%s/1/a<bs>", - ":%s/1/ax", - ":%s/1/ax<bs>", - ":%s/1/ax<bs><bs>", - ":%s/1/ax<bs><bs><bs>", - ":%s/1/ax/", - ":%s/1/ax/<bs>", - ":%s/1/ax/<bs>/", - ":%s/1/ax/g", - ":%s/1/ax/g<bs>", - ":%s/1/ax/g<bs><bs>" + { ':%s/', '1' }, + { ':%s/', '1', '/' }, + { ':%s/', '1', '/', '<bs>' }, + { ':%s/', '1', '/', 'a' }, + { ':%s/', '1', '/', 'a', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x' }, + { ':%s/', '1', '/', 'a', 'x', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x', '<bs>', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x', '<bs>', '<bs>', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x', '/' }, + { ':%s/', '1', '/', 'a', 'x', '/', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x', '/', '<bs>', '/' }, + { ':%s/', '1', '/', 'a', 'x', '/', 'g' }, + { ':%s/', '1', '/', 'a', 'x', '/', 'g', '<bs>' }, + { ':%s/', '1', '/', 'a', 'x', '/', 'g', '<bs>', '<bs>' }, } local function test_sub(substring, split, redoable) command('bwipe!') - feed_command("set inccommand=" .. split) + command('set inccommand=' .. split) - insert("1") - feed("o2<esc>") - feed_command("undo") - feed("o3<esc>") + insert('1') + feed('o2<esc>') + command('undo') + feed('o3<esc>') if redoable then - feed("o4<esc>") - feed_command("undo") + feed('o4<esc>') + command('undo') + end + for _, s in pairs(substring) do + feed(s) end - feed(substring.. "<enter>") - feed_command("undo") + poke_eventloop() + feed('<enter>') + command('undo') - feed("g-") + feed('g-') expect([[ 1 2]]) - feed("g+") + feed('g+') expect([[ 1 3]]) @@ -371,30 +399,34 @@ describe(":substitute, 'inccommand' preserves undo", function() local function test_notsub(substring, split, redoable) command('bwipe!') - feed_command("set inccommand=" .. split) + command('set inccommand=' .. split) - insert("1") - feed("o2<esc>") - feed_command("undo") - feed("o3<esc>") + insert('1') + feed('o2<esc>') + command('undo') + feed('o3<esc>') if redoable then - feed("o4<esc>") - feed_command("undo") + feed('o4<esc>') + command('undo') + end + for _, s in pairs(substring) do + feed(s) end - feed(substring .. "<esc>") + poke_eventloop() + feed('<esc>') - feed("g-") + feed('g-') expect([[ 1 2]]) - feed("g+") + feed('g+') expect([[ 1 3]]) if redoable then - feed("<c-r>") + feed('<c-r>') expect([[ 1 3 @@ -402,20 +434,19 @@ describe(":substitute, 'inccommand' preserves undo", function() end end - local function test_threetree(substring, split) command('bwipe!') - feed_command("set inccommand=" .. split) - - insert("1") - feed("o2<esc>") - feed("o3<esc>") - feed("uu") - feed("oa<esc>") - feed("ob<esc>") - feed("uu") - feed("oA<esc>") - feed("oB<esc>") + command('set inccommand=' .. split) + + insert('1') + feed('o2<esc>') + feed('o3<esc>') + feed('uu') + feed('oa<esc>') + feed('ob<esc>') + feed('uu') + feed('oA<esc>') + feed('oB<esc>') -- This is the undo tree (x-Axis is timeline), we're at B now -- ----------------A - B @@ -424,33 +455,45 @@ describe(":substitute, 'inccommand' preserves undo", function() -- |/ -- 1 - 2 - 3 - feed("2u") - feed(substring .. "<esc>") + feed('2u') + for _, s in pairs(substring) do + feed(s) + poke_eventloop() + end + feed('<esc>') expect([[ 1]]) - feed("g-") + feed('g-') expect([[ ]]) - feed("g+") + feed('g+') expect([[ 1]]) - feed("<c-r>") + feed('<c-r>') expect([[ 1 A]]) - feed("g-") -- go to b - feed("2u") - feed(substring .. "<esc>") - feed("<c-r>") + feed('g-') -- go to b + feed('2u') + for _, s in pairs(substring) do + feed(s) + poke_eventloop() + end + feed('<esc>') + feed('<c-r>') expect([[ 1 a]]) - feed("g-") -- go to 3 - feed("2u") - feed(substring .. "<esc>") - feed("<c-r>") + feed('g-') -- go to 3 + feed('2u') + for _, s in pairs(substring) do + feed(s) + poke_eventloop() + end + feed('<esc>') + feed('<c-r>') expect([[ 1 2]]) @@ -458,37 +501,37 @@ describe(":substitute, 'inccommand' preserves undo", function() before_each(clear) - it("at a non-leaf of the undo tree", function() - for _, case in pairs(cases) do - for _, str in pairs(substrings) do - for _, redoable in pairs({true}) do - test_sub(str, case, redoable) - end - end - end + it('at a non-leaf of the undo tree', function() + for _, case in pairs(cases) do + for _, str in pairs(substrings) do + for _, redoable in pairs({ true }) do + test_sub(str, case, redoable) + end + end + end end) - it("at a leaf of the undo tree", function() + it('at a leaf of the undo tree', function() for _, case in pairs(cases) do for _, str in pairs(substrings) do - for _, redoable in pairs({false}) do + for _, redoable in pairs({ false }) do test_sub(str, case, redoable) end end end end) - it("when interrupting substitution", function() + it('when interrupting substitution', function() for _, case in pairs(cases) do for _, str in pairs(substrings) do - for _, redoable in pairs({true,false}) do + for _, redoable in pairs({ true, false }) do test_notsub(str, case, redoable) end end end end) - it("in a complex undo scenario", function() + it('in a complex undo scenario', function() for _, case in pairs(cases) do for _, str in pairs(substrings) do test_threetree(str, case) @@ -500,28 +543,32 @@ describe(":substitute, 'inccommand' preserves undo", function() for _, case in pairs(cases) do clear() common_setup(nil, case, default_text) - feed_command("set undolevels=0") + command('set undolevels=0') - feed("1G0") - insert("X") - feed(":%s/tw/MO/<esc>") - feed_command("undo") + feed('1G0') + insert('X') + feed(':%s/tw/MO/') + poke_eventloop() + feed('<esc>') + command('undo') expect(default_text) - feed_command("undo") - expect(default_text:gsub("Inc", "XInc")) - feed_command("undo") + command('undo') + expect(default_text:gsub('Inc', 'XInc')) + command('undo') - feed_command("%s/tw/MO/g") - expect(default_text:gsub("tw", "MO")) - feed_command("undo") + feed(':%s/tw/MO/g') + poke_eventloop() + feed('<CR>') + expect(default_text:gsub('tw', 'MO')) + command('undo') expect(default_text) - feed_command("undo") - expect(default_text:gsub("tw", "MO")) + command('undo') + expect(default_text:gsub('tw', 'MO')) end end) it('with undolevels=1', function() - local screen = Screen.new(20,10) + local screen = Screen.new(20, 10) for _, case in pairs(cases) do clear() @@ -530,46 +577,43 @@ describe(":substitute, 'inccommand' preserves undo", function() Inc substitution on | two lines | ^ | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 | ]]) - feed_command("set undolevels=1") - - feed("1G0") - insert("X") - feed("IY<esc>") - feed(":%s/tw/MO/<esc>") - -- feed_command("undo") here would cause "Press ENTER". - feed("u") - expect(default_text:gsub("Inc", "XInc")) - feed("u") + command('set undolevels=1') + + feed('1G0') + insert('X') + feed('IY<esc>') + feed(':%s/tw/MO/') + poke_eventloop() + feed('<esc>') + feed('u') + expect(default_text:gsub('Inc', 'XInc')) + feed('u') expect(default_text) - feed(":%s/tw/MO/g<enter>") - feed(":%s/MO/GO/g<enter>") - feed(":%s/GO/NO/g<enter>") - feed("u") - expect(default_text:gsub("tw", "GO")) - feed("u") - expect(default_text:gsub("tw", "MO")) - feed("u") + feed(':%s/tw/MO/g') + poke_eventloop() + feed('<enter>') + feed(':%s/MO/GO/g') + poke_eventloop() + feed('<enter>') + feed(':%s/GO/NO/g') + poke_eventloop() + feed('<enter>') + feed('u') + expect(default_text:gsub('tw', 'GO')) + feed('u') + expect(default_text:gsub('tw', 'MO')) + feed('u') - if case == "split" then + if case == 'split' then screen:expect([[ Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) else @@ -577,12 +621,7 @@ describe(":substitute, 'inccommand' preserves undo", function() Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) end @@ -590,37 +629,33 @@ describe(":substitute, 'inccommand' preserves undo", function() end) it('with undolevels=2', function() - local screen = Screen.new(20,10) + local screen = Screen.new(20, 10) for _, case in pairs(cases) do clear() common_setup(screen, case, default_text) - feed_command("set undolevels=2") - - feed("2GAx<esc>") - feed("Ay<esc>") - feed("Az<esc>") - feed(":%s/tw/AR<esc>") - -- feed_command("undo") here would cause "Press ENTER". - feed("u") - expect(default_text:gsub("lines", "linesxy")) - feed("u") - expect(default_text:gsub("lines", "linesx")) - feed("u") + command('set undolevels=2') + + feed('2GAx<esc>') + feed('Ay<esc>') + feed('Az<esc>') + feed(':%s/tw/AR') + poke_eventloop() + feed('<esc>') + feed('u') + expect(default_text:gsub('lines', 'linesxy')) + feed('u') + expect(default_text:gsub('lines', 'linesx')) + feed('u') expect(default_text) - feed("u") + feed('u') - if case == "split" then + if case == 'split' then screen:expect([[ Inc substitution on | two line^s | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) else @@ -628,39 +663,37 @@ describe(":substitute, 'inccommand' preserves undo", function() Inc substitution on | two line^s | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) end - feed(":%s/tw/MO/g<enter>") - feed(":%s/MO/GO/g<enter>") - feed(":%s/GO/NO/g<enter>") - feed(":%s/NO/LO/g<enter>") - feed("u") - expect(default_text:gsub("tw", "NO")) - feed("u") - expect(default_text:gsub("tw", "GO")) - feed("u") - expect(default_text:gsub("tw", "MO")) - feed("u") - - if case == "split" then + feed(':%s/tw/MO/g') + poke_eventloop() + feed('<enter>') + feed(':%s/MO/GO/g') + poke_eventloop() + feed('<enter>') + feed(':%s/GO/NO/g') + poke_eventloop() + feed('<enter>') + feed(':%s/NO/LO/g') + poke_eventloop() + feed('<enter>') + feed('u') + expect(default_text:gsub('tw', 'NO')) + feed('u') + expect(default_text:gsub('tw', 'GO')) + feed('u') + expect(default_text:gsub('tw', 'MO')) + feed('u') + + if case == 'split' then screen:expect([[ Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) else @@ -668,12 +701,7 @@ describe(":substitute, 'inccommand' preserves undo", function() Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) end @@ -681,27 +709,23 @@ describe(":substitute, 'inccommand' preserves undo", function() end) it('with undolevels=-1', function() - local screen = Screen.new(20,10) + local screen = Screen.new(20, 10) for _, case in pairs(cases) do clear() common_setup(screen, case, default_text) - feed_command("set undolevels=-1") - feed(":%s/tw/MO/g<enter>") - -- feed_command("undo") here will result in a "Press ENTER" prompt - feed("u") - if case == "split" then + command('set undolevels=-1') + feed(':%s/tw/MO/g') + poke_eventloop() + feed('<enter>') + feed('u') + if case == 'split' then screen:expect([[ Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) else @@ -709,12 +733,7 @@ describe(":substitute, 'inccommand' preserves undo", function() Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) end @@ -723,41 +742,37 @@ describe(":substitute, 'inccommand' preserves undo", function() clear() common_setup(screen, case, default_text) - feed_command("set undolevels=-1") - feed("1G") - feed("IL<esc>") - feed(":%s/tw/MO/g<esc>") - feed("u") + command('set undolevels=-1') + feed('1G') + feed('IL<esc>') + feed(':%s/tw/MO/g') + poke_eventloop() + feed('<esc>') + feed('u') screen:expect([[ ^LInc substitution on| two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 Already ...t change | ]]) end end) - end) -describe(":substitute, inccommand=split", function() +describe(':substitute, inccommand=split', function() local screen before_each(function() clear() - screen = Screen.new(30,15) - common_setup(screen, "split", default_text .. default_text) + screen = Screen.new(30, 15) + common_setup(screen, 'split', default_text .. default_text) end) it("preserves 'modified' buffer flag", function() - feed_command("set nomodified") - feed(":%s/tw") + command('set nomodified') + feed(':%s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | @@ -767,30 +782,26 @@ describe(":substitute, inccommand=split", function() {11:[No Name] }| |2| {12:tw}o lines | |4| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw^ | ]]) - feed([[<C-\><C-N>]]) -- Cancel the :substitute command. - eq(0, eval("&modified")) + feed([[<C-\><C-N>]]) -- Cancel the :substitute command. + eq(0, eval('&modified')) end) - it("shows preview when cmd modifiers are present", function() + it('shows preview when cmd modifiers are present', function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect{any=[[{12:to}o lines]]} + screen:expect { any = [[{12:to}o lines]] } feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect{any=[[{12:to}o lines]]} + screen:expect { any = [[{12:to}o lines]] } feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } -- non-modifier prefix feed(':silent tabedit %s/tw/to') @@ -800,27 +811,19 @@ describe(":substitute, inccommand=split", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :silent tabedit %s/tw/to^ | ]]) feed('<Esc>') -- leading colons feed(':::%s/tw/to') - screen:expect{any=[[{12:to}o lines]]} + screen:expect { any = [[{12:to}o lines]] } feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } end) - it("ignores new-window modifiers when splitting the preview window", function() + it('ignores new-window modifiers when splitting the preview window', function() -- one modifier feed(':topleft %s/tw/to') screen:expect([[ @@ -832,16 +835,12 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:to}o lines | |4| {12:to}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :topleft %s/tw/to^ | ]]) feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } -- multiple modifiers feed(':topleft vert %s/tw/to') @@ -854,20 +853,16 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:to}o lines | |4| {12:to}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :topleft vert %s/tw/to^ | ]]) feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } end) it('shows split window when typing the pattern', function() - feed(":%s/tw") + feed(':%s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | @@ -877,18 +872,14 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:tw}o lines | |4| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw^ | ]]) end) it('shows preview with empty replacement', function() - feed(":%s/tw/") + feed(':%s/tw/') screen:expect([[ Inc substitution on | o lines | @@ -898,16 +889,12 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw/^ | ]]) - feed("x") + feed('x') screen:expect([[ Inc substitution on | {12:x}o lines | @@ -917,16 +904,12 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:x}o lines | |4| {12:x}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw/x^ | ]]) - feed("<bs>") + feed('<bs>') screen:expect([[ Inc substitution on | o lines | @@ -936,19 +919,14 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| o lines | |4| o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw/^ | ]]) - end) it('shows split window when typing replacement', function() - feed(":%s/tw/XX") + feed(':%s/tw/XX') screen:expect([[ Inc substitution on | {12:XX}o lines | @@ -958,41 +936,29 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:XX}o lines | |4| {12:XX}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw/XX^ | ]]) end) it('does not show split window for :s/', function() - feed("2gg") - feed(":s/tw") + feed('2gg') + feed(':s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :s/tw^ | ]]) end) it("'hlsearch' is active, 'cursorline' is not", function() - feed_command("set hlsearch cursorline") - feed("gg") + command('set hlsearch cursorline') + feed('gg') -- Assert that 'cursorline' is active. screen:expect([[ @@ -1001,19 +967,11 @@ describe(":substitute, inccommand=split", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - :set hlsearch cursorline | + {15:~ }|*9 + | ]]) - feed(":%s/tw") + feed(':%s/tw') -- 'cursorline' is NOT active during preview. screen:expect([[ Inc substitution on | @@ -1024,11 +982,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |2| {12:tw}o lines | |4| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/tw^ | ]]) @@ -1046,12 +1000,7 @@ describe(":substitute, inccommand=split", function() two lines | {11:[No Name] [+] }| |1| {12:123} {12:123} {12:123} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/M/123/g^ | ]]) @@ -1068,33 +1017,20 @@ describe(":substitute, inccommand=split", function() | {11:[No Name] [+] }| | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/Inx^ | ]]) end) it('previews correctly when previewhight is small', function() - feed_command('set cwh=3') - feed_command('set hls') + command('set cwh=3') + command('set hls') feed('ggdG') insert(string.rep('abc abc abc\n', 20)) feed(':%s/abc/MMM/g') screen:expect([[ - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | - {12:MMM} {12:MMM} {12:MMM} | + {12:MMM} {12:MMM} {12:MMM} |*9 {11:[No Name] [+] }| | 1| {12:MMM} {12:MMM} {12:MMM} | | 2| {12:MMM} {12:MMM} {12:MMM} | @@ -1105,7 +1041,9 @@ describe(":substitute, inccommand=split", function() end) it('actually replaces text', function() - feed(":%s/tw/XX/g<Enter>") + feed(':%s/tw/XX/g') + poke_eventloop() + feed('<Enter>') screen:expect([[ Inc substitution on | @@ -1113,32 +1051,24 @@ describe(":substitute, inccommand=split", function() Inc substitution on | ^XXo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :%s/tw/XX/g | ]]) end) it('shows correct line numbers with many lines', function() - feed("gg") - feed("2yy") - feed("2000p") - feed_command("1,1000s/tw/BB/g") + feed('gg') + feed('2yy') + feed('2000p') + command('1,1000s/tw/BB/g') - feed(":%s/tw/X") + feed(':%s/tw/X') screen:expect([[ + Inc substitution on | BBo lines | Inc substitution on | {12:X}o lines | Inc substitution on | - {12:X}o lines | {11:[No Name] [+] }| |1001| {12:X}o lines | |1003| {12:X}o lines | @@ -1155,58 +1085,52 @@ describe(":substitute, inccommand=split", function() it('does not spam the buffer numbers', function() -- The preview buffer is re-used (unless user deleted it), so buffer numbers -- will not increase on each keystroke. - feed(":%s/tw/Xo/g") + feed(':%s/tw/Xo/g') -- Delete and re-type the g a few times. - feed("<BS>") + feed('<BS>') poke_eventloop() - feed("g") + feed('g') poke_eventloop() - feed("<BS>") + feed('<BS>') poke_eventloop() - feed("g") + feed('g') poke_eventloop() - feed("<CR>") + feed('<CR>') poke_eventloop() - feed(":vs tmp<enter>") - eq(3, helpers.call('bufnr', '$')) + feed(':vs tmp<enter>') + eq(3, fn.bufnr('$')) end) it('works with the n flag', function() - feed(":%s/tw/Mix/n<Enter>") + feed(':%s/tw/Mix/n') + poke_eventloop() + feed('<Enter>') screen:expect([[ Inc substitution on | two lines | Inc substitution on | two lines | ^ | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 2 matches on 2 lines | ]]) end) it("deactivates if 'redrawtime' is exceeded #5602", function() -- prevent redraws from 'incsearch' - meths.set_option_value('incsearch', false, {}) + api.nvim_set_option_value('incsearch', false, {}) -- Assert that 'inccommand' is ENABLED initially. - eq("split", eval("&inccommand")) + eq('split', eval('&inccommand')) -- Set 'redrawtime' to minimal value, to ensure timeout is triggered. - feed_command("set redrawtime=1 nowrap") + command('set redrawtime=1 nowrap') -- Load a big file. - feed_command("silent edit! test/functional/fixtures/bigfile_oneline.txt") + command('silent edit! test/functional/fixtures/bigfile_oneline.txt') -- Start :substitute with a slow pattern. feed([[:%s/B.*N/x]]) poke_eventloop() -- Assert that 'inccommand' is DISABLED in cmdline mode. - eq("", eval("&inccommand")) + eq('', eval('&inccommand')) -- Assert that preview cleared (or never manifested). screen:expect([[ 0000;<control>;Cc;0;BN;;;;;N;N| @@ -1228,7 +1152,7 @@ describe(":substitute, inccommand=split", function() -- Assert that 'inccommand' is again ENABLED after leaving cmdline mode. feed([[<C-\><C-N>]]) - eq("split", eval("&inccommand")) + eq('split', eval('&inccommand')) end) it("deactivates if 'foldexpr' is slow #9557", function() @@ -1264,12 +1188,12 @@ describe(":substitute, inccommand=split", function() end) end) - it("clears preview if non-previewable command is edited #5585", function() + it('clears preview if non-previewable command is edited #5585', function() feed('gg') -- Put a non-previewable command in history. - feed_command("echo 'foo'") + feed(":echo 'foo'<CR>") -- Start an incomplete :substitute command. - feed(":1,2s/t/X") + feed(':1,2s/t/X') screen:expect([[ Inc subs{12:X}itution on | @@ -1280,17 +1204,13 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:X}itution on | |2| {12:X}wo lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :1,2s/t/X^ | ]]) -- Select the previous command. - feed("<C-P>") + feed('<C-P>') -- Assert that preview was cleared. screen:expect([[ Inc substitution on | @@ -1298,22 +1218,14 @@ describe(":substitute, inccommand=split", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :echo 'foo'^ | ]]) end) it([[preview changes correctly with c_CTRL-R_= and c_CTRL-\_e]], function() feed('gg') - feed(":1,2s/t/X") + feed(':1,2s/t/X') screen:expect([[ Inc subs{12:X}itution on | {12:X}wo lines | @@ -1323,11 +1235,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:X}itution on | |2| {12:X}wo lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :1,2s/t/X^ | ]]) @@ -1343,11 +1251,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:X}itution on | |2| {12:X}wo lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| ={1:'Y'}^ | ]]) @@ -1363,11 +1267,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:XY}itution on | |2| {12:XY}wo lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :1,2s/t/XY^ | ]]) @@ -1383,11 +1283,7 @@ describe(":substitute, inccommand=split", function() {11:[No Name] [+] }| |1| Inc subs{12:XY}itution on | |2| {12:XY}wo lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| ={1:'echo'}^ | ]]) @@ -1400,76 +1296,61 @@ describe(":substitute, inccommand=split", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :echo^ | ]]) end) - end) -describe("inccommand=nosplit", function() +describe('inccommand=nosplit', function() local screen before_each(function() clear() - screen = Screen.new(20,10) - common_setup(screen, "nosplit", default_text .. default_text) + screen = Screen.new(20, 10) + common_setup(screen, 'nosplit', default_text .. default_text) end) - it("works with :smagic, :snomagic", function() - feed_command("set hlsearch") - insert("Line *.3.* here") + it('works with :smagic, :snomagic', function() + command('set hlsearch') + insert('Line *.3.* here') - feed(":%smagic/3.*/X") -- start :smagic command + feed(':%smagic/3.*/X') -- start :smagic command screen:expect([[ Inc substitution on | two lines | Inc substitution on | two lines | Line *.{12:X} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%smagic/3.*/X^ | ]]) - feed([[<C-\><C-N>]]) -- cancel - feed(":%snomagic/3.*/X") -- start :snomagic command + feed([[<C-\><C-N>]]) -- cancel + feed(':%snomagic/3.*/X') -- start :snomagic command screen:expect([[ Inc substitution on | two lines | Inc substitution on | two lines | Line *.{12:X} here | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%snomagic/3.*/X^ | ]]) end) - it("shows preview when cmd modifiers are present", function() + it('shows preview when cmd modifiers are present', function() -- one modifier feed(':keeppatterns %s/tw/to') - screen:expect{any=[[{12:to}o lines]]} + screen:expect { any = [[{12:to}o lines]] } feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } -- multiple modifiers feed(':keeppatterns silent %s/tw/to') - screen:expect{any=[[{12:to}o lines]]} + screen:expect { any = [[{12:to}o lines]] } feed('<Esc>') - screen:expect{any=[[two lines]]} + screen:expect { any = [[two lines]] } -- non-modifier prefix feed(':silent tabedit %s/tw/to') @@ -1479,22 +1360,21 @@ describe("inccommand=nosplit", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11: }| :silent tabedit %s/t| w/to^ | ]]) end) - it("does not show window after toggling :set inccommand", function() - feed(":%s/tw/OKOK") - feed("<Esc>") - command("set icm=split") - feed(":%s/tw/OKOK") - feed("<Esc>") - command("set icm=nosplit") - feed(":%s/tw/OKOK") + it('does not show window after toggling :set inccommand', function() + feed(':%s/tw/OKOK') + feed('<Esc>') + command('set icm=split') + feed(':%s/tw/OKOK') + feed('<Esc>') + command('set icm=nosplit') + feed(':%s/tw/OKOK') poke_eventloop() screen:expect([[ Inc substitution on | @@ -1502,79 +1382,64 @@ describe("inccommand=nosplit", function() Inc substitution on | {12:OKOK}o lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/tw/OKOK^ | ]]) end) it('never shows preview buffer', function() - feed_command("set hlsearch") + command('set hlsearch') - feed(":%s/tw") + feed(':%s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | Inc substitution on | {12:tw}o lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/tw^ | ]]) - feed("/BM") + feed('/BM') screen:expect([[ Inc substitution on | {12:BM}o lines | Inc substitution on | {12:BM}o lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/tw/BM^ | ]]) - feed("/") + feed('/') screen:expect([[ Inc substitution on | {12:BM}o lines | Inc substitution on | {12:BM}o lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/tw/BM/^ | ]]) - feed("<enter>") + feed('<enter>') screen:expect([[ Inc substitution on | BMo lines | Inc substitution on | ^BMo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/tw/BM/ | ]]) end) - it("clears preview if non-previewable command is edited", function() + it('clears preview if non-previewable command is edited', function() -- Put a non-previewable command in history. - feed_command("echo 'foo'") + feed(":echo 'foo'<CR>") -- Start an incomplete :substitute command. - feed(":1,2s/t/X") + feed(':1,2s/t/X') screen:expect([[ Inc subs{12:X}itution on | @@ -1582,15 +1447,12 @@ describe("inccommand=nosplit", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :1,2s/t/X^ | ]]) -- Select the previous command. - feed("<C-P>") + feed('<C-P>') -- Assert that preview was cleared. screen:expect([[ Inc substitution on | @@ -1598,15 +1460,12 @@ describe("inccommand=nosplit", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :echo 'foo'^ | ]]) end) - it("does not execute trailing bar-separated commands #7494", function() + it('does not execute trailing bar-separated commands #7494', function() feed(':%s/two/three/g|q!') screen:expect([[ Inc substitution on | @@ -1614,16 +1473,13 @@ describe("inccommand=nosplit", function() Inc substitution on | {12:three} lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/two/three/g|q!^ | ]]) eq(eval('v:null'), eval('v:exiting')) end) - it("does not break bar-separated command #8796", function() + it('does not break bar-separated command #8796', function() source([[ function! F() if v:false | return | endif @@ -1631,17 +1487,14 @@ describe("inccommand=nosplit", function() ]]) command('call timer_start(10, {-> F()}, {"repeat":-1})') feed(':%s/') - sleep(20) -- Allow some timer activity. + sleep(20) -- Allow some timer activity. screen:expect([[ Inc substitution on | two lines | Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :%s/^ | ]]) end) @@ -1649,19 +1502,21 @@ end) describe(":substitute, 'inccommand' with a failing expression", function() local screen - local cases = { "", "split", "nosplit" } + local cases = { '', 'split', 'nosplit' } local function refresh(case) clear() - screen = Screen.new(20,10) + screen = Screen.new(20, 10) common_setup(screen, case, default_text) end it('in the pattern does nothing', function() for _, case in pairs(cases) do refresh(case) - feed_command("set inccommand=" .. case) - feed(":silent! %s/tw\\(/LARD/<enter>") + command('set inccommand=' .. case) + feed(':silent! %s/tw\\(/LARD/') + poke_eventloop() + feed('<enter>') expect(default_text) end end) @@ -1669,13 +1524,15 @@ describe(":substitute, 'inccommand' with a failing expression", function() it('in the replacement deletes the matches', function() for _, case in pairs(cases) do refresh(case) - local replacements = { "\\='LARD", "\\=xx_novar__xx" } + local replacements = { "\\='LARD", '\\=xx_novar__xx' } for _, repl in pairs(replacements) do - feed_command("set inccommand=" .. case) - feed(":silent! %s/tw/" .. repl .. "/<enter>") - expect(default_text:gsub("tw", "")) - feed_command("undo") + command('set inccommand=' .. case) + feed(':silent! %s/tw/' .. repl .. '/') + poke_eventloop() + feed('<enter>') + expect(default_text:gsub('tw', '')) + command('undo') end end end) @@ -1689,12 +1546,7 @@ describe(":substitute, 'inccommand' with a failing expression", function() Inc substitution on | two lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 :100s/^ | ]]) @@ -1703,88 +1555,101 @@ describe(":substitute, 'inccommand' with a failing expression", function() Inc substitution on | two lines | ^ | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {14:E16: Invalid range} | ]]) end end) - end) describe("'inccommand' and :cnoremap", function() - local cases = { "", "split", "nosplit" } + local cases = { '', 'split', 'nosplit' } local screen local function refresh(case, visual) clear() - screen = visual and Screen.new(80,10) or nil + screen = visual and Screen.new(80, 10) or nil common_setup(screen, case, default_text) end it('work with remapped characters', function() for _, case in pairs(cases) do refresh(case) - local cmd = "%s/lines/LINES/g" + local cmd = '%s/lines/LINES/g' for i = 1, string.len(cmd) do local c = string.sub(cmd, i, i) - feed_command("cnoremap ".. c .. " " .. c) + command('cnoremap ' .. c .. ' ' .. c) end - feed_command(cmd) + feed(':' .. cmd) + poke_eventloop() + feed('<CR>') expect([[ Inc substitution on two LINES ]]) - end + end end) it('work when mappings move the cursor', function() for _, case in pairs(cases) do refresh(case) - feed_command("cnoremap ,S LINES/<left><left><left><left><left><left>") + command('cnoremap ,S LINES/<left><left><left><left><left><left>') - feed(":%s/lines/,Sor three <enter>") + feed(':%s/lines/') + poke_eventloop() + feed(',S') + poke_eventloop() + feed('or three <enter>') + poke_eventloop() expect([[ Inc substitution on two or three LINES ]]) - feed_command("cnoremap ;S /X/<left><left><left>") - feed(":%s/;SI<enter>") + command('cnoremap ;S /X/<left><left><left>') + feed(':%s/') + poke_eventloop() + feed(';S') + poke_eventloop() + feed('I<enter>') expect([[ Xnc substitution on two or three LXNES ]]) - feed_command("cnoremap ,T //Y/<left><left><left>") - feed(":%s,TX<enter>") + command('cnoremap ,T //Y/<left><left><left>') + feed(':%s') + poke_eventloop() + feed(',T') + poke_eventloop() + feed('X<enter>') expect([[ Ync substitution on two or three LYNES ]]) - feed_command("cnoremap ;T s//Z/<left><left><left>") - feed(":%;TY<enter>") + command('cnoremap ;T s//Z/<left><left><left>') + feed(':%') + poke_eventloop() + feed(';T') + poke_eventloop() + feed('Y<enter>') expect([[ Znc substitution on two or three LZNES ]]) - end + end end) it('still works with a broken mapping', function() for _, case in pairs(cases) do refresh(case, true) - feed_command("cnoremap <expr> x execute('bwipeout!')[-1].'x'") + command("cnoremap <expr> x execute('bwipeout!')[-1].'x'") - feed(":%s/tw/tox<enter>") - screen:expect{any=[[{14:^E565:]]} + feed(':%s/tw/tox<enter>') + screen:expect { any = [[{14:^E565:]] } feed('<c-c>') -- error thrown b/c of the mapping @@ -1799,20 +1664,24 @@ describe("'inccommand' and :cnoremap", function() it('work when temporarily moving the cursor', function() for _, case in pairs(cases) do refresh(case) - feed_command("cnoremap <expr> x cursor(1, 1)[-1].'x'") + command("cnoremap <expr> x cursor(1, 1)[-1].'x'") - feed(":%s/tw/tox/g<enter>") - expect(default_text:gsub("tw", "tox")) + feed(':%s/tw/tox') + poke_eventloop() + feed('/g<enter>') + expect(default_text:gsub('tw', 'tox')) end end) it("work when a mapping disables 'inccommand'", function() for _, case in pairs(cases) do refresh(case) - feed_command("cnoremap <expr> x execute('set inccommand=')[-1]") + command("cnoremap <expr> x execute('set inccommand=')[-1]") - feed(":%s/tw/toxa/g<enter>") - expect(default_text:gsub("tw", "toa")) + feed(':%s/tw/tox') + poke_eventloop() + feed('a/g<enter>') + expect(default_text:gsub('tw', 'toa')) end end) @@ -1822,12 +1691,12 @@ describe("'inccommand' and :cnoremap", function() source([[cnoremap x <C-\>eextend(g:, {'fo': getcmdline()}) \.fo<CR><C-c>:new<CR>:bw!<CR>:<C-r>=remove(g:, 'fo')<CR>x]]) - feed(":%s/tw/tox") - feed("/<enter>") - expect(default_text:gsub("tw", "tox")) + feed(':%s/tw/tox') + poke_eventloop() + feed('/<enter>') + expect(default_text:gsub('tw', 'tox')) end end) - end) describe("'inccommand' autocommands", function() @@ -1868,9 +1737,9 @@ describe("'inccommand' autocommands", function() } local function bufferlist(t) - local s = "" + local s = '' for _, buffer in pairs(t) do - s = s .. ", " .. tostring(buffer) + s = s .. ', ' .. tostring(buffer) end return s end @@ -1882,12 +1751,12 @@ describe("'inccommand' autocommands", function() end local function register_autocmd(event) - meths.set_var(event .. "_fired", {}) - feed_command("autocmd " .. event .. " * call add(g:" .. event .. "_fired, expand('<abuf>'))") + api.nvim_set_var(event .. '_fired', {}) + command('autocmd ' .. event .. ' * call add(g:' .. event .. "_fired, expand('<abuf>'))") end it('are not fired when splitting', function() - common_setup(nil, "split", default_text) + common_setup(nil, 'split', default_text) local eventsObserved = {} for event, _ in pairs(eventsExpected) do @@ -1895,162 +1764,112 @@ describe("'inccommand' autocommands", function() register_autocmd(event) end - feed(":%s/tw") + feed(':%s/tw') for event, _ in pairs(eventsExpected) do - eventsObserved[event].open = meths.get_var(event .. "_fired") - meths.set_var(event .. "_fired", {}) + eventsObserved[event].open = api.nvim_get_var(event .. '_fired') + api.nvim_set_var(event .. '_fired', {}) end - feed("/<enter>") + feed('/<enter>') for event, _ in pairs(eventsExpected) do - eventsObserved[event].close = meths.get_var(event .. "_fired") + eventsObserved[event].close = api.nvim_get_var(event .. '_fired') end for event, _ in pairs(eventsExpected) do - eq(event .. bufferlist(eventsExpected[event].open), - event .. bufferlist(eventsObserved[event].open)) - eq(event .. bufferlist(eventsExpected[event].close), - event .. bufferlist(eventsObserved[event].close)) + eq( + event .. bufferlist(eventsExpected[event].open), + event .. bufferlist(eventsObserved[event].open) + ) + eq( + event .. bufferlist(eventsExpected[event].close), + event .. bufferlist(eventsObserved[event].close) + ) end end) - end) describe("'inccommand' split windows", function() local screen local function refresh() clear() - screen = Screen.new(40,30) - common_setup(screen, "split", default_text) + screen = Screen.new(40, 30) + common_setup(screen, 'split', default_text) end it('work after more splits', function() refresh() - feed("gg") - feed_command("vsplit") - feed_command("split") - feed(":%s/tw") + feed('gg') + command('vsplit') + command('split') + feed(':%s/tw') screen:expect([[ Inc substitution on │Inc substitution on| {12:tw}o lines │{12:tw}o lines | │ | - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| + {15:~ }│{15:~ }|*11 {11:[No Name] [+] }│{15:~ }| Inc substitution on │{15:~ }| {12:tw}o lines │{15:~ }| │{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| + {15:~ }│{15:~ }|*2 {10:[No Name] [+] [No Name] [+] }| |2| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/tw^ | ]]) - feed("<esc>") - feed_command("only") - feed_command("split") - feed_command("vsplit") + feed('<esc>') + command('only') + command('split') + command('vsplit') - feed(":%s/tw") + feed(':%s/tw') screen:expect([[ Inc substitution on │Inc substitution on| {12:tw}o lines │{12:tw}o lines | │ | - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| - {15:~ }│{15:~ }| + {15:~ }│{15:~ }|*11 {11:[No Name] [+] }{10:[No Name] [+] }| Inc substitution on | {12:tw}o lines | | - {15:~ }| - {15:~ }| + {15:~ }|*2 {10:[No Name] [+] }| |2| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/tw^ | ]]) end) local settings = { - "splitbelow", - "splitright", - "noequalalways", - "equalalways eadirection=ver", - "equalalways eadirection=hor", - "equalalways eadirection=both", + 'splitbelow', + 'splitright', + 'noequalalways', + 'equalalways eadirection=ver', + 'equalalways eadirection=hor', + 'equalalways eadirection=both', } - it("are not affected by various settings", function() + it('are not affected by various settings', function() for _, setting in pairs(settings) do refresh() - feed_command("set " .. setting) + command('set ' .. setting) - feed(":%s/tw") + feed(':%s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*17 {11:[No Name] [+] }| |2| {12:tw}o lines | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/tw^ | ]]) @@ -2060,7 +1879,7 @@ describe("'inccommand' split windows", function() it("don't open if there's not enough room", function() refresh() screen:try_resize(40, 3) - feed("gg:%s/tw") + feed('gg:%s/tw') screen:expect([[ Inc substitution on | {12:tw}o lines | @@ -2074,43 +1893,43 @@ describe("'inccommand' with 'gdefault'", function() clear() end) - it("does not lock up #7244", function() - common_setup(nil, "nosplit", "{") - command("set gdefault") - feed(":s/{\\n") - eq({mode='c', blocking=false}, nvim("get_mode")) - feed("/A<Enter>") - expect("A") - eq({mode='n', blocking=false}, nvim("get_mode")) + it('does not lock up #7244', function() + common_setup(nil, 'nosplit', '{') + command('set gdefault') + feed(':s/{\\n') + eq({ mode = 'c', blocking = false }, api.nvim_get_mode()) + feed('/A<Enter>') + expect('A') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) end) - it("with multiline text and range, does not lock up #7244", function() - common_setup(nil, "nosplit", "{\n\n{") - command("set gdefault") - feed(":%s/{\\n") - eq({mode='c', blocking=false}, nvim("get_mode")) - feed("/A<Enter>") - expect("A\nA") - eq({mode='n', blocking=false}, nvim("get_mode")) + it('with multiline text and range, does not lock up #7244', function() + common_setup(nil, 'nosplit', '{\n\n{') + command('set gdefault') + feed(':%s/{\\n') + eq({ mode = 'c', blocking = false }, api.nvim_get_mode()) + feed('/A<Enter>') + expect('A\nA') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) end) - it("does not crash on zero-width matches #7485", function() - common_setup(nil, "split", default_text) - command("set gdefault") - feed("gg") - feed("Vj") - feed(":s/\\%V") - eq({mode='c', blocking=false}, nvim("get_mode")) - feed("<Esc>") - eq({mode='n', blocking=false}, nvim("get_mode")) + it('does not crash on zero-width matches #7485', function() + common_setup(nil, 'split', default_text) + command('set gdefault') + feed('gg') + feed('Vj') + feed(':s/\\%V') + eq({ mode = 'c', blocking = false }, api.nvim_get_mode()) + feed('<Esc>') + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) end) - it("removes highlights after abort for a zero-width match", function() - local screen = Screen.new(30,5) - common_setup(screen, "nosplit", default_text) - command("set gdefault") + it('removes highlights after abort for a zero-width match', function() + local screen = Screen.new(30, 5) + common_setup(screen, 'nosplit', default_text) + command('set gdefault') - feed(":%s/\\%1c/a/") + feed(':%s/\\%1c/a/') screen:expect([[ {12:a}Inc substitution on | {12:a}two lines | @@ -2119,7 +1938,7 @@ describe("'inccommand' with 'gdefault'", function() :%s/\%1c/a/^ | ]]) - feed("<Esc>") + feed('<Esc>') screen:expect([[ Inc substitution on | two lines | @@ -2128,21 +1947,20 @@ describe("'inccommand' with 'gdefault'", function() | ]]) end) - end) -describe(":substitute", function() +describe(':substitute', function() local screen before_each(function() clear() - screen = Screen.new(30,15) + screen = Screen.new(30, 15) end) - it("inccommand=split, highlights multiline substitutions", function() - common_setup(screen, "split", multiline_text) - feed("gg") + it('inccommand=split, highlights multiline substitutions', function() + common_setup(screen, 'split', multiline_text) + feed('gg') - feed(":%s/2\\_.*X") + feed(':%s/2\\_.*X') screen:expect([[ 1 {12:2 3} | {12:A B C} | @@ -2154,33 +1972,25 @@ describe(":substitute", function() |2|{12: A B C} | |3|{12: 4 5 6} | |4|{12: X} Y Z | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {10:[Preview] }| :%s/2\_.*X^ | ]]) - feed("/MMM") + feed('/MMM') screen:expect([[ 1 {12:MMM} Y Z | 7 8 9 | | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |1| 1 {12:MMM} Y Z | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/2\_.*X/MMM^ | ]]) - feed("\\rK\\rLLL") + feed('\\rK\\rLLL') screen:expect([[ 1 {12:MMM} | {12:K} | @@ -2191,113 +2001,77 @@ describe(":substitute", function() |1| 1 {12:MMM} | |2|{12: K} | |3|{12: LLL} Y Z | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 {10:[Preview] }| :%s/2\_.*X/MMM\rK\rLLL^ | ]]) end) - it("inccommand=nosplit, highlights multiline substitutions", function() - common_setup(screen, "nosplit", multiline_text) - feed("gg") + it('inccommand=nosplit, highlights multiline substitutions', function() + common_setup(screen, 'nosplit', multiline_text) + feed('gg') - feed(":%s/2\\_.*X/MMM") + feed(':%s/2\\_.*X/MMM') screen:expect([[ 1 {12:MMM} Y Z | 7 8 9 | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*11 :%s/2\_.*X/MMM^ | ]]) - feed("\\rK\\rLLL") + feed('\\rK\\rLLL') screen:expect([[ 1 {12:MMM} | {12:K} | {12:LLL} Y Z | 7 8 9 | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*9 :%s/2\_.*X/MMM\rK\rLLL^ | ]]) end) - it("inccommand=split, highlights multiple matches on a line", function() - common_setup(screen, "split", multimatch_text) - command("set gdefault") - feed("gg") + it('inccommand=split, highlights multiple matches on a line', function() + common_setup(screen, 'split', multimatch_text) + command('set gdefault') + feed('gg') - feed(":%s/a/XLK") + feed(':%s/a/XLK') screen:expect([[ {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| x | | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |1| {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:X}| {12:LK} r | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/a/XLK^ | ]]) end) - it("inccommand=nosplit, highlights multiple matches on a line", function() - common_setup(screen, "nosplit", multimatch_text) - command("set gdefault") - feed("gg") + it('inccommand=nosplit, highlights multiple matches on a line', function() + common_setup(screen, 'nosplit', multimatch_text) + command('set gdefault') + feed('gg') - feed(":%s/a/XLK") + feed(':%s/a/XLK') screen:expect([[ {12:XLK} bdc e{12:XLK}e {12:XLK} fgl lzi{12:XLK} r| x | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*11 :%s/a/XLK^ | ]]) end) - it("inccommand=split, with \\zs", function() - common_setup(screen, "split", multiline_text) - feed("gg") + it('inccommand=split, with \\zs', function() + common_setup(screen, 'split', multiline_text) + feed('gg') - feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + feed(':%s/[0-9]\\n\\zs[A-Z]/OKO') screen:expect([[ {12:OKO} B C | 4 5 6 | @@ -2309,19 +2083,17 @@ describe(":substitute", function() |2| {12:OKO} B C | |3| 4 5 6 | |4| {12:OKO} Y Z | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {10:[Preview] }| :%s/[0-9]\n\zs[A-Z]/OKO^ | ]]) end) - it("inccommand=nosplit, with \\zs", function() - common_setup(screen, "nosplit", multiline_text) - feed("gg") + it('inccommand=nosplit, with \\zs', function() + common_setup(screen, 'nosplit', multiline_text) + feed('gg') - feed(":%s/[0-9]\\n\\zs[A-Z]/OKO") + feed(':%s/[0-9]\\n\\zs[A-Z]/OKO') screen:expect([[ 1 2 3 | {12:OKO} B C | @@ -2329,65 +2101,41 @@ describe(":substitute", function() {12:OKO} Y Z | 7 8 9 | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*8 :%s/[0-9]\n\zs[A-Z]/OKO^ | ]]) end) - it("inccommand=split, substitutions of different length", function() - common_setup(screen, "split", "T T123 T2T TTT T090804\nx") + it('inccommand=split, substitutions of different length', function() + common_setup(screen, 'split', 'T T123 T2T TTT T090804\nx') - feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + feed(':%s/T\\([0-9]\\+\\)/\\1\\1/g') screen:expect([[ T {12:123123} {12:22}T TTT {12:090804090804} | x | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {11:[No Name] [+] }| |1| T {12:123123} {12:22}T TTT {12:090804090}| {12:804} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 {10:[Preview] }| :%s/T\([0-9]\+\)/\1\1/g^ | ]]) end) - it("inccommand=nosplit, substitutions of different length", function() - common_setup(screen, "nosplit", "T T123 T2T TTT T090804\nx") + it('inccommand=nosplit, substitutions of different length', function() + common_setup(screen, 'nosplit', 'T T123 T2T TTT T090804\nx') - feed(":%s/T\\([0-9]\\+\\)/\\1\\1/g") + feed(':%s/T\\([0-9]\\+\\)/\\1\\1/g') screen:expect([[ T {12:123123} {12:22}T TTT {12:090804090804} | x | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*12 :%s/T\([0-9]\+\)/\1\1/g^ | ]]) end) - it("inccommand=split, contraction of lines", function() + it('inccommand=split, contraction of lines', function() local text = [[ T T123 T T123 T2T TT T23423424 x @@ -2396,8 +2144,8 @@ describe(":substitute", function() alx ]] - common_setup(screen, "split", text) - feed(":%s/[QR]\\n") + common_setup(screen, 'split', text) + feed(':%s/[QR]\\n') screen:expect([[ afa {12:Q} | adf la;lkd {12:R} | @@ -2408,15 +2156,12 @@ describe(":substitute", function() |3| afa {12:Q} | |4|{12: }adf la;lkd {12:R} | |5|{12: }alx | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 {10:[Preview] }| :%s/[QR]\n^ | ]]) - feed("/KKK") + feed('/KKK') screen:expect([[ T T123 T T123 T2T TT T23423424| x | @@ -2425,18 +2170,13 @@ describe(":substitute", function() {15:~ }| {11:[No Name] [+] }| |3| afa {12:KKK}adf la;lkd {12:KKK}alx | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/[QR]\n/KKK^ | ]]) end) - it("inccommand=nosplit, contraction of lines", function() + it('inccommand=nosplit, contraction of lines', function() local text = [[ T T123 T T123 T2T TT T23423424 x @@ -2445,28 +2185,19 @@ describe(":substitute", function() alx ]] - common_setup(screen, "nosplit", text) - feed(":%s/[QR]\\n/KKK") + common_setup(screen, 'nosplit', text) + feed(':%s/[QR]\\n/KKK') screen:expect([[ T T123 T T123 T2T TT T23423424| x | afa {12:KKK}adf la;lkd {12:KKK}alx | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*10 :%s/[QR]\n/KKK^ | ]]) end) - it("inccommand=split, contraction of two subsequent NL chars", function() + it('inccommand=split, contraction of two subsequent NL chars', function() local text = [[ AAA AA @@ -2478,9 +2209,10 @@ describe(":substitute", function() -- This used to crash, but more than 20 highlight entries are required -- to reproduce it (so that the marktree has multiple nodes) - common_setup(screen, "split", string.rep(text,10)) - feed(":%s/\\n\\n/<c-v><c-m>/g") - screen:expect{grid=[[ + common_setup(screen, 'split', string.rep(text, 10)) + feed(':%s/\\n\\n/<c-v><c-m>/g') + screen:expect { + grid = [[ CCC CC | AAA AA | BBB BB | @@ -2496,11 +2228,12 @@ describe(":substitute", function() | 7|{12: }AAA AA | {10:[Preview] }| :%s/\n\n/{17:^M}/g^ | - ]]} + ]], + } assert_alive() end) - it("inccommand=nosplit, contraction of two subsequent NL chars", function() + it('inccommand=nosplit, contraction of two subsequent NL chars', function() local text = [[ AAA AA @@ -2510,9 +2243,10 @@ describe(":substitute", function() ]] - common_setup(screen, "nosplit", string.rep(text,10)) - feed(":%s/\\n\\n/<c-v><c-m>/g") - screen:expect{grid=[[ + common_setup(screen, 'nosplit', string.rep(text, 10)) + feed(':%s/\\n\\n/<c-v><c-m>/g') + screen:expect { + grid = [[ CCC CC | AAA AA | BBB BB | @@ -2528,13 +2262,14 @@ describe(":substitute", function() CCC CC | | :%s/\n\n/{17:^M}/g^ | - ]]} + ]], + } assert_alive() end) - it("inccommand=split, multibyte text", function() - common_setup(screen, "split", multibyte_text) - feed(":%s/£.*ѫ/X¥¥") + it('inccommand=split, multibyte text', function() + common_setup(screen, 'split', multibyte_text) + feed(':%s/£.*ѫ/X¥¥') screen:expect([[ a{12:X¥¥}¥KOL | £ ¥ libm | @@ -2545,15 +2280,12 @@ describe(":substitute", function() |1| {12:X¥¥} PEPPERS | |2| {12:X¥¥} | |3| a{12:X¥¥}¥KOL | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 {10:[Preview] }| :%s/£.*ѫ/X¥¥^ | ]]) - feed("\\ra££ ¥") + feed('\\ra££ ¥') screen:expect([[ a{12:X¥¥} | {12:a££ ¥}¥KOL | @@ -2573,9 +2305,9 @@ describe(":substitute", function() ]]) end) - it("inccommand=nosplit, multibyte text", function() - common_setup(screen, "nosplit", multibyte_text) - feed(":%s/£.*ѫ/X¥¥") + it('inccommand=nosplit, multibyte text', function() + common_setup(screen, 'nosplit', multibyte_text) + feed(':%s/£.*ѫ/X¥¥') screen:expect([[ {12:X¥¥} PEPPERS | {12:X¥¥} | @@ -2583,18 +2315,11 @@ describe(":substitute", function() £ ¥ libm | £ ¥ | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*8 :%s/£.*ѫ/X¥¥^ | ]]) - feed("\\ra££ ¥") + feed('\\ra££ ¥') screen:expect([[ {12:X¥¥} | {12:a££ ¥} PEPPERS | @@ -2605,20 +2330,16 @@ describe(":substitute", function() £ ¥ libm | £ ¥ | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*5 :%s/£.*ѫ/X¥¥\ra££ ¥^ | ]]) end) - it("inccommand=split, small cmdwinheight", function() - common_setup(screen, "split", long_multiline_text) - command("set cmdwinheight=2") + it('inccommand=split, small cmdwinheight', function() + common_setup(screen, 'split', long_multiline_text) + command('set cmdwinheight=2') - feed(":%s/[a-z]") + feed(':%s/[a-z]') screen:expect([[ X Y Z | 7 8 9 | @@ -2637,7 +2358,7 @@ describe(":substitute", function() :%s/[a-z]^ | ]]) - feed("/JLKR £") + feed('/JLKR £') screen:expect([[ X Y Z | 7 8 9 | @@ -2656,7 +2377,7 @@ describe(":substitute", function() :%s/[a-z]/JLKR £^ | ]]) - feed("\\rѫ ab \\rXXXX") + feed('\\rѫ ab \\rXXXX') screen:expect([[ 7 8 9 | K L M | @@ -2676,11 +2397,11 @@ describe(":substitute", function() ]]) end) - it("inccommand=split, large cmdwinheight", function() - common_setup(screen, "split", long_multiline_text) - command("set cmdwinheight=11") + it('inccommand=split, large cmdwinheight', function() + common_setup(screen, 'split', long_multiline_text) + command('set cmdwinheight=11') - feed(":%s/. .$") + feed(':%s/. .$') screen:expect([[ t {12:œ ¥} | {11:[No Name] [+] }| @@ -2699,7 +2420,7 @@ describe(":substitute", function() :%s/. .$^ | ]]) - feed("/ YYY") + feed('/ YYY') screen:expect([[ t {12: YYY} | {11:[No Name] [+] }| @@ -2718,7 +2439,7 @@ describe(":substitute", function() :%s/. .$/ YYY^ | ]]) - feed("\\r KKK") + feed('\\r KKK') screen:expect([[ a {12: YYY} | {11:[No Name] [+] }| @@ -2738,28 +2459,22 @@ describe(":substitute", function() ]]) end) - it("inccommand=split, lookaround", function() - common_setup(screen, "split", "something\neverything\nsomeone") + it('inccommand=split, lookaround', function() + common_setup(screen, 'split', 'something\neverything\nsomeone') feed([[:%s/\(some\)\@<lt>=thing/one/]]) screen:expect([[ some{12:one} | everything | someone | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |1| some{12:one} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/\(some\)\@<=thing/one/^ | ]]) - feed("<C-c>") + feed('<C-c>') feed('gg') poke_eventloop() feed([[:%s/\(some\)\@<lt>!thing/one/]]) @@ -2767,16 +2482,10 @@ describe(":substitute", function() something | every{12:one} | someone | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |2| every{12:one} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/\(some\)\@<!thing/one/^ | ]]) @@ -2788,16 +2497,10 @@ describe(":substitute", function() {12:every}thing | everything | someone | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |1| {12:every}thing | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/some\(thing\)\@=/every/^ | ]]) @@ -2809,16 +2512,10 @@ describe(":substitute", function() something | everything | {12:every}one | - {15:~ }| - {15:~ }| + {15:~ }|*2 {11:[No Name] [+] }| |3| {12:every}one | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*6 {10:[Preview] }| :%s/some\(thing\)\@!/every/^ | ]]) @@ -2826,7 +2523,7 @@ describe(":substitute", function() it("doesn't prompt to swap cmd range", function() screen = Screen.new(50, 8) -- wide to avoid hit-enter prompt - common_setup(screen, "split", default_text) + common_setup(screen, 'split', default_text) feed(':2,1s/tw/MO/g') -- substitution preview should have been made, without prompting @@ -2834,9 +2531,7 @@ describe(":substitute", function() {12:MO}o lines | {11:[No Name] [+] }| |2| {12:MO}o lines | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {10:[Preview] }| :2,1s/tw/MO/g^ | ]]) @@ -2847,9 +2542,7 @@ describe(":substitute", function() {12:MO}o lines | {11:[No Name] [+] }| |2| {12:MO}o lines | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {10:[Preview] }| {13:Backwards range given, OK to swap (y/n)?}^ | ]]) @@ -2859,10 +2552,7 @@ describe(":substitute", function() Inc substitution on | ^MOo lines | | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 {13:Backwards range given, OK to swap (y/n)?}y | ]]) end) @@ -2874,19 +2564,19 @@ it(':substitute with inccommand during :terminal activity', function() end retry(2, 40000, function() clear() - local screen = Screen.new(30,15) + local screen = Screen.new(30, 15) - command("set cmdwinheight=3") + command('set cmdwinheight=3') feed(([[:terminal "%s" REP 5000 xxx<cr>]]):format(testprg('shell-test'))) command('file term') - feed('G') -- Follow :terminal output. + feed('G') -- Follow :terminal output. command('new') common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('wincmd =') feed('gg') feed(':%s/foo/ZZZ') - sleep(20) -- Allow some terminal activity. + sleep(20) -- Allow some terminal activity. poke_eventloop() screen:sleep(0) screen:expect_unchanged() @@ -2895,7 +2585,7 @@ end) it(':substitute with inccommand, timer-induced :redraw #9777', function() clear() - local screen = Screen.new(30,12) + local screen = Screen.new(30, 12) command('set cmdwinheight=3') command('call timer_start(10, {-> execute("redraw")}, {"repeat":-1})') command('call timer_start(10, {-> execute("redrawstatus")}, {"repeat":-1})') @@ -2903,14 +2593,12 @@ it(':substitute with inccommand, timer-induced :redraw #9777', function() feed('gg') feed(':%s/foo/ZZZ') - sleep(20) -- Allow some timer activity. + sleep(20) -- Allow some timer activity. screen:expect([[ {12:ZZZ} bar baz | bar baz fox | bar {12:ZZZ} baz | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 {11:[No Name] [+] }| |1| {12:ZZZ} bar baz | |3| bar {12:ZZZ} baz | @@ -2922,12 +2610,17 @@ end) it(':substitute with inccommand, allows :redraw before first separator is typed #18857', function() clear() - local screen = Screen.new(30,6) + local screen = Screen.new(30, 6) common_setup(screen, 'split', 'foo bar baz\nbar baz fox\nbar foo baz') command('hi! link NormalFloat CursorLine') - local float_buf = meths.create_buf(false, true) - meths.open_win(float_buf, false, { - relative = 'editor', height = 1, width = 5, row = 3, col = 0, focusable = false, + local float_buf = api.nvim_create_buf(false, true) + api.nvim_open_win(float_buf, false, { + relative = 'editor', + height = 1, + width = 5, + row = 3, + col = 0, + focusable = false, }) feed(':') screen:expect([[ @@ -2947,7 +2640,7 @@ it(':substitute with inccommand, allows :redraw before first separator is typed {15:~ }| :%s^ | ]]) - meths.buf_set_lines(float_buf, 0, -1, true, {'foo'}) + api.nvim_buf_set_lines(float_buf, 0, -1, true, { 'foo' }) command('redraw') screen:expect([[ foo bar baz | @@ -2966,10 +2659,7 @@ it(':substitute with inccommand, does not crash if range contains invalid marks' feed([[:'a,'bs]]) screen:expect([[ test | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :'a,'bs^ | ]]) -- v:errmsg shouldn't be set either before the first separator is typed @@ -2977,10 +2667,7 @@ it(':substitute with inccommand, does not crash if range contains invalid marks' feed('/') screen:expect([[ test | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :'a,'bs/^ | ]]) end) @@ -3030,17 +2717,14 @@ it(':substitute with inccommand, no unnecessary redraw if preview is not shown', -- now inccommand is shown, so screen is redrawn screen:expect([[ {12:test} | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :s/test^ | ]]) end) it(":substitute doesn't crash with inccommand, if undo is empty #12932", function() clear() - local screen = Screen.new(10,5) + local screen = Screen.new(10, 5) command('set undolevels=-1') common_setup(screen, 'split', 'test') feed(':%s/test') @@ -3050,9 +2734,7 @@ it(":substitute doesn't crash with inccommand, if undo is empty #12932", functio feed('f') screen:expect([[ {12:f} | - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*3 :%s/test/f^ | ]]) assert_alive() @@ -3062,7 +2744,7 @@ it(':substitute with inccommand works properly if undo is not synced #20029', fu clear() local screen = Screen.new(30, 6) common_setup(screen, 'nosplit', 'foo\nbar\nbaz') - meths.set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {}) + api.nvim_set_keymap('x', '<F2>', '<Esc>`<Oaaaaa asdf<Esc>`>obbbbb asdf<Esc>V`<k:s/asdf/', {}) feed('gg0<C-V>lljj<F2>') screen:expect([[ aaaaa | @@ -3127,10 +2809,31 @@ end) it('long :%s/ with inccommand does not collapse cmdline', function() clear() - local screen = Screen.new(10,5) + local screen = Screen.new(10, 5) common_setup(screen, 'nosplit') - feed(':%s/AAAAAAA', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', - 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A') + feed( + ':%s/AAAAAAA', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A', + 'A' + ) screen:expect([[ | {11: }| @@ -3147,10 +2850,7 @@ it("with 'inccommand' typing invalid `={expr}` does not show error", function() feed(':edit `=`') screen:expect([[ | - {15:~ }| - {15:~ }| - {15:~ }| - {15:~ }| + {15:~ }|*4 :edit `=`^ | ]]) end) @@ -3195,3 +2895,54 @@ it("'inccommand' cannot be changed during preview #23136", function() feed(':%s/foo/bar<C-E><C-E><C-E>') assert_alive() end) + +it("'inccommand' value can be changed multiple times #27086", function() + clear() + local screen = Screen.new(30, 20) + common_setup(screen, 'split', 'foo1\nfoo2\nfoo3') + for _ = 1, 3 do + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*7 + {11:[No Name] [+] }| + |1| {12:bar}1 | + |2| {12:bar}2 | + |3| {12:bar}3 | + {15:~ }|*4 + {10:[Preview] }| + :%s/foo/bar^ | + ]]) + feed('<Esc>') + command('set inccommand=nosplit') + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*16 + :%s/foo/bar^ | + ]]) + feed('<Esc>') + command('set inccommand=split') + end +end) + +it("'inccommand' disables preview if preview buffer can't be created #27086", function() + clear() + api.nvim_buf_set_name(0, '[Preview]') + local screen = Screen.new(30, 20) + common_setup(screen, 'split', 'foo1\nfoo2\nfoo3') + eq('split', api.nvim_get_option_value('inccommand', {})) + feed(':%s/foo/bar') + screen:expect([[ + {12:bar}1 | + {12:bar}2 | + {12:bar}3 | + {15:~ }|*16 + :%s/foo/bar^ | + ]]) + eq('nosplit', api.nvim_get_option_value('inccommand', {})) +end) diff --git a/test/functional/ui/inccommand_user_spec.lua b/test/functional/ui/inccommand_user_spec.lua index da7508fad1..a714df72b7 100644 --- a/test/functional/ui/inccommand_user_spec.lua +++ b/test/functional/ui/inccommand_user_spec.lua @@ -1,6 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') +local api = helpers.api local clear = helpers.clear +local eq = helpers.eq local exec_lua = helpers.exec_lua local insert = helpers.insert local feed = helpers.feed @@ -236,16 +238,16 @@ describe("'inccommand' for user commands", function() clear() screen = Screen.new(40, 17) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow1}, - [2] = {foreground = Screen.colors.Blue1, bold = true}, - [3] = {reverse = true}, - [4] = {reverse = true, bold = true}, - [5] = {foreground = Screen.colors.Blue}, + [1] = { background = Screen.colors.Yellow1 }, + [2] = { foreground = Screen.colors.Blue1, bold = true }, + [3] = { reverse = true }, + [4] = { reverse = true, bold = true }, + [5] = { foreground = Screen.colors.Blue }, }) screen:attach() exec_lua(setup_replace_cmd) command('set cmdwinheight=5') - insert[[ + insert [[ text on line 1 more text on line 2 oh no, even more text @@ -270,13 +272,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the {1:cats} stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Replace text cats^ | ]]) end) @@ -318,13 +314,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 | ]]) end) @@ -342,13 +332,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the cats stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Replace text cats | ]]) end) @@ -366,13 +350,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :.Replace text cats^ | ]]) end) @@ -425,13 +403,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the cats stop | | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :C^ | ]]) assert_alive() @@ -481,13 +453,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | a.a.a.a. | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Test a.a.a.a.^ | ]]) feed('<C-V><Esc>u') @@ -501,13 +467,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | a.a.a. | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 :Test a.a.a.a.{5:^[}u^ | ]]) feed('<Esc>') @@ -521,13 +481,7 @@ describe("'inccommand' for user commands", function() why won't it stop | make the text stop | ^ | - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| - {2:~ }| + {2:~ }|*7 | ]]) end @@ -543,6 +497,22 @@ describe("'inccommand' for user commands", function() test_preview_break_undo() end) end) + + it('disables preview if preview buffer cannot be created #27086', function() + command('set inccommand=split') + api.nvim_buf_set_name(0, '[Preview]') + exec_lua([[ + vim.api.nvim_create_user_command('Test', function() end, { + nargs = '*', + preview = function(_, _, _) + return 2 + end + }) + ]]) + eq('split', api.nvim_get_option_value('inccommand', {})) + feed(':Test') + eq('nosplit', api.nvim_get_option_value('inccommand', {})) + end) end) describe("'inccommand' with multiple buffers", function() @@ -552,21 +522,21 @@ describe("'inccommand' with multiple buffers", function() clear() screen = Screen.new(40, 17) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow1}, - [2] = {foreground = Screen.colors.Blue1, bold = true}, - [3] = {reverse = true}, - [4] = {reverse = true, bold = true} + [1] = { background = Screen.colors.Yellow1 }, + [2] = { foreground = Screen.colors.Blue1, bold = true }, + [3] = { reverse = true }, + [4] = { reverse = true, bold = true }, }) screen:attach() exec_lua(setup_replace_cmd) command('set cmdwinheight=10') - insert[[ + insert [[ foo bar baz bar baz foo baz foo bar ]] command('vsplit | enew') - insert[[ + insert [[ bar baz foo baz foo bar foo bar baz @@ -581,17 +551,7 @@ describe("'inccommand' with multiple buffers", function() baz {1:bar} bar │ bar baz {1:bar} | {1:bar} bar baz │ baz {1:bar} bar | │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar^ | ]]) @@ -601,17 +561,7 @@ describe("'inccommand' with multiple buffers", function() baz bar bar │ bar baz bar | bar bar baz │ baz bar bar | ^ │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar | ]]) @@ -645,17 +595,7 @@ describe("'inccommand' with multiple buffers", function() baz bar bar │ bar baz bar | bar bar baz │ baz bar bar | ^ │ | - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| - {2:~ }│{2:~ }| + {2:~ }│{2:~ }|*11 {4:[No Name] [+] }{3:[No Name] [+] }| :Replace foo bar | ]]) diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 05d55b94fb..b2899bf82d 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -4,10 +4,10 @@ local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq local command = helpers.command local expect = helpers.expect local curbuf_contents = helpers.curbuf_contents -local meths = helpers.meths +local api = helpers.api local exec_lua = helpers.exec_lua local write_file = helpers.write_file -local funcs = helpers.funcs +local fn = helpers.fn local eval = helpers.eval local Screen = require('test.functional.ui.screen') @@ -15,17 +15,24 @@ before_each(clear) describe('mappings', function() local add_mapping = function(mapping, send) - local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '" - ..send:gsub('<', '<lt>').."')<cr>" + local cmd = 'nnoremap ' + .. mapping + .. " :call rpcnotify(1, 'mapped', '" + .. send:gsub('<', '<lt>') + .. "')<cr>" feed_command(cmd) end local check_mapping = function(mapping, expected) feed(mapping) - eq({'notification', 'mapped', {expected}}, next_msg()) + eq({ 'notification', 'mapped', { expected } }, next_msg()) end before_each(function() + add_mapping('<A-l>', '<A-l>') + add_mapping('<A-L>', '<A-L>') + add_mapping('<D-l>', '<D-l>') + add_mapping('<D-L>', '<D-L>') add_mapping('<C-L>', '<C-L>') add_mapping('<C-S-L>', '<C-S-L>') add_mapping('<s-up>', '<s-up>') @@ -35,30 +42,40 @@ describe('mappings', function() add_mapping('<c-s-a-d-up>', '<c-s-a-d-up>') add_mapping('<c-d-a>', '<c-d-a>') add_mapping('<d-1>', '<d-1>') - add_mapping('<khome>','<khome>') - add_mapping('<kup>','<kup>') - add_mapping('<kpageup>','<kpageup>') - add_mapping('<kleft>','<kleft>') - add_mapping('<korigin>','<korigin>') - add_mapping('<kright>','<kright>') - add_mapping('<kend>','<kend>') - add_mapping('<kdown>','<kdown>') - add_mapping('<kpagedown>','<kpagedown>') - add_mapping('<kinsert>','<kinsert>') - add_mapping('<kdel>','<kdel>') - add_mapping('<kdivide>','<kdivide>') - add_mapping('<kmultiply>','<kmultiply>') - add_mapping('<kminus>','<kminus>') - add_mapping('<kplus>','<kplus>') - add_mapping('<kenter>','<kenter>') - add_mapping('<kcomma>','<kcomma>') - add_mapping('<kequal>','<kequal>') - add_mapping('<f38>','<f38>') - add_mapping('<f63>','<f63>') + add_mapping('<khome>', '<khome>') + add_mapping('<kup>', '<kup>') + add_mapping('<kpageup>', '<kpageup>') + add_mapping('<kleft>', '<kleft>') + add_mapping('<korigin>', '<korigin>') + add_mapping('<kright>', '<kright>') + add_mapping('<kend>', '<kend>') + add_mapping('<kdown>', '<kdown>') + add_mapping('<kpagedown>', '<kpagedown>') + add_mapping('<kinsert>', '<kinsert>') + add_mapping('<kdel>', '<kdel>') + add_mapping('<kdivide>', '<kdivide>') + add_mapping('<kmultiply>', '<kmultiply>') + add_mapping('<kminus>', '<kminus>') + add_mapping('<kplus>', '<kplus>') + add_mapping('<kenter>', '<kenter>') + add_mapping('<kcomma>', '<kcomma>') + add_mapping('<kequal>', '<kequal>') + add_mapping('<f38>', '<f38>') + add_mapping('<f63>', '<f63>') end) it('ok', function() + check_mapping('<A-l>', '<A-l>') + check_mapping('<A-L>', '<A-L>') + check_mapping('<A-S-l>', '<A-L>') + check_mapping('<A-S-L>', '<A-L>') + check_mapping('<D-l>', '<D-l>') + check_mapping('<D-L>', '<D-L>') + check_mapping('<D-S-l>', '<D-L>') + check_mapping('<D-S-L>', '<D-L>') + check_mapping('<C-l>', '<C-L>') check_mapping('<C-L>', '<C-L>') + check_mapping('<C-S-l>', '<C-S-L>') check_mapping('<C-S-L>', '<C-S-L>') check_mapping('<s-up>', '<s-up>') check_mapping('<c-s-up>', '<c-s-up>') @@ -75,44 +92,44 @@ describe('mappings', function() check_mapping('<c-d-a>', '<c-d-a>') check_mapping('<d-c-a>', '<c-d-a>') check_mapping('<d-1>', '<d-1>') - check_mapping('<khome>','<khome>') - check_mapping('<KP7>','<khome>') - check_mapping('<kup>','<kup>') - check_mapping('<KP8>','<kup>') - check_mapping('<kpageup>','<kpageup>') - check_mapping('<KP9>','<kpageup>') - check_mapping('<kleft>','<kleft>') - check_mapping('<KP4>','<kleft>') - check_mapping('<korigin>','<korigin>') - check_mapping('<KP5>','<korigin>') - check_mapping('<kright>','<kright>') - check_mapping('<KP6>','<kright>') - check_mapping('<kend>','<kend>') - check_mapping('<KP1>','<kend>') - check_mapping('<kdown>','<kdown>') - check_mapping('<KP2>','<kdown>') - check_mapping('<kpagedown>','<kpagedown>') - check_mapping('<KP3>','<kpagedown>') - check_mapping('<kinsert>','<kinsert>') - check_mapping('<KP0>','<kinsert>') - check_mapping('<kdel>','<kdel>') - check_mapping('<KPPeriod>','<kdel>') - check_mapping('<kdivide>','<kdivide>') - check_mapping('<KPDiv>','<kdivide>') - check_mapping('<kmultiply>','<kmultiply>') - check_mapping('<KPMult>','<kmultiply>') - check_mapping('<kminus>','<kminus>') - check_mapping('<KPMinus>','<kminus>') - check_mapping('<kplus>','<kplus>') - check_mapping('<KPPlus>','<kplus>') - check_mapping('<kenter>','<kenter>') - check_mapping('<KPEnter>','<kenter>') - check_mapping('<kcomma>','<kcomma>') - check_mapping('<KPComma>','<kcomma>') - check_mapping('<kequal>','<kequal>') - check_mapping('<KPEquals>','<kequal>') - check_mapping('<f38>','<f38>') - check_mapping('<f63>','<f63>') + check_mapping('<khome>', '<khome>') + check_mapping('<KP7>', '<khome>') + check_mapping('<kup>', '<kup>') + check_mapping('<KP8>', '<kup>') + check_mapping('<kpageup>', '<kpageup>') + check_mapping('<KP9>', '<kpageup>') + check_mapping('<kleft>', '<kleft>') + check_mapping('<KP4>', '<kleft>') + check_mapping('<korigin>', '<korigin>') + check_mapping('<KP5>', '<korigin>') + check_mapping('<kright>', '<kright>') + check_mapping('<KP6>', '<kright>') + check_mapping('<kend>', '<kend>') + check_mapping('<KP1>', '<kend>') + check_mapping('<kdown>', '<kdown>') + check_mapping('<KP2>', '<kdown>') + check_mapping('<kpagedown>', '<kpagedown>') + check_mapping('<KP3>', '<kpagedown>') + check_mapping('<kinsert>', '<kinsert>') + check_mapping('<KP0>', '<kinsert>') + check_mapping('<kdel>', '<kdel>') + check_mapping('<KPPeriod>', '<kdel>') + check_mapping('<kdivide>', '<kdivide>') + check_mapping('<KPDiv>', '<kdivide>') + check_mapping('<kmultiply>', '<kmultiply>') + check_mapping('<KPMult>', '<kmultiply>') + check_mapping('<kminus>', '<kminus>') + check_mapping('<KPMinus>', '<kminus>') + check_mapping('<kplus>', '<kplus>') + check_mapping('<KPPlus>', '<kplus>') + check_mapping('<kenter>', '<kenter>') + check_mapping('<KPEnter>', '<kenter>') + check_mapping('<kcomma>', '<kcomma>') + check_mapping('<KPComma>', '<kcomma>') + check_mapping('<kequal>', '<kequal>') + check_mapping('<KPEquals>', '<kequal>') + check_mapping('<f38>', '<f38>') + check_mapping('<f63>', '<f63>') end) it('support meta + multibyte char mapping', function() @@ -151,7 +168,7 @@ describe('input split utf sequences', function() it('ok', function() local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('►') end) @@ -160,7 +177,7 @@ describe('input split utf sequences', function() command('inoremap ► E296BA') local str = '►' feed('i' .. str:sub(1, 1)) - helpers.sleep(10) + vim.uv.sleep(10) feed(str:sub(2, 3)) expect('E296BA') end) @@ -241,7 +258,7 @@ it('Ctrl-6 is Ctrl-^ vim-patch:8.1.2333', function() command('split aaa') command('edit bbb') feed('<C-6>') - eq('aaa', funcs.bufname()) + eq('aaa', fn.bufname()) end) it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8.1.2346', function() @@ -262,20 +279,18 @@ it('c_CTRL-R_CTRL-R, i_CTRL-R_CTRL-R, i_CTRL-G_CTRL-K work properly vim-patch:8. end) it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2.0839', function() - local screen = Screen.new(60,8) + local screen = Screen.new(60, 8) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [2] = {bold = true, reverse = true}, -- MsgSeparator - [3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- MsgSeparator + [3] = { bold = true, foreground = Screen.colors.SeaGreen }, -- MoreMsg }) screen:attach() command([[nnoremap <C-6> <Cmd>echo 'hit ctrl-6'<CR>]]) feed_command('ls') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2: }| :ls | 1 %a "[No Name]" line 1 | @@ -284,12 +299,7 @@ it('typing a simplifiable key at hit-enter prompt triggers mapping vim-patch:8.2 feed('<C-6>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 hit ctrl-6 | ]]) end) @@ -307,7 +317,7 @@ it('unsimplified mapping works when there was a partial match vim-patch:8.2.4504 command('nnoremap <C-J> a') command('nnoremap <NL> x') command('nnoremap <C-J>x <Nop>') - funcs.setline(1, 'x') + fn.setline(1, 'x') -- CTRL-J b should have trigger the <C-J> mapping and then insert "b" feed('<C-J>b<Esc>') expect('xb') @@ -319,49 +329,41 @@ describe('input non-printable chars', function() end) it("doesn't crash when echoing them back", function() - write_file("Xtest-overwrite", [[foobar]]) - local screen = Screen.new(60,8) + write_file('Xtest-overwrite', [[foobar]]) + local screen = Screen.new(60, 8) screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; - [3] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [4] = {bold = true, reverse = true}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [4] = { bold = true, reverse = true }, } screen:attach() - command("set shortmess-=F") + command('set shortmess-=F') - feed_command("e Xtest-overwrite") + feed_command('e Xtest-overwrite') screen:expect([[ ^foobar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 "Xtest-overwrite" [noeol] 1L, 6B | ]]) -- The timestamp is in second resolution, wait two seconds to be sure. screen:sleep(2000) - write_file("Xtest-overwrite", [[smurf]]) - feed_command("w") + write_file('Xtest-overwrite', [[smurf]]) + feed_command('w') screen:expect([[ foobar | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("u") + feed('u') screen:expect([[ foobar | - {1:~ }| - {1:~ }| + {1:~ }|*2 {4: }| "Xtest-overwrite" | {2:WARNING: The file has been changed since reading it!!!} | @@ -369,7 +371,7 @@ describe('input non-printable chars', function() {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("\005") + feed('\005') screen:expect([[ foobar | {1:~ }| @@ -381,7 +383,7 @@ describe('input non-printable chars', function() {3:Do you really want to write to it (y/n)?}^ | ]]) - feed("n") + feed('n') screen:expect([[ foobar | {4: }| @@ -393,23 +395,23 @@ describe('input non-printable chars', function() {3:Press ENTER or type command to continue}^ | ]]) - feed("<cr>") + feed('<cr>') screen:expect([[ ^foobar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) end) -describe("event processing and input", function() +describe('event processing and input', function() it('not blocked by event bursts', function() - meths.set_keymap('', '<f2>', "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", {noremap=true}) + api.nvim_set_keymap( + '', + '<f2>', + "<cmd>lua vim.rpcnotify(1, 'stop') winning = true <cr>", + { noremap = true } + ) exec_lua [[ winning = false @@ -425,9 +427,9 @@ describe("event processing and input", function() burst(true) ]] - eq({'notification', 'start', {}}, next_msg()) + eq({ 'notification', 'start', {} }, next_msg()) feed '<f2>' - eq({'notification', 'stop', {}}, next_msg()) + eq({ 'notification', 'stop', {} }, next_msg()) end) end) @@ -436,8 +438,8 @@ describe('display is updated', function() before_each(function() screen = Screen.new(60, 8) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, -- NonText - [2] = {bold = true}, -- ModeMsg + [1] = { bold = true, foreground = Screen.colors.Blue1 }, -- NonText + [2] = { bold = true }, -- ModeMsg }) screen:attach() end) @@ -449,11 +451,7 @@ describe('display is updated', function() screen:expect([[ abc | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end) @@ -465,11 +463,7 @@ describe('display is updated', function() screen:expect([[ abc | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end) diff --git a/test/functional/ui/linematch_spec.lua b/test/functional/ui/linematch_spec.lua index ef47ea7ed0..40df5cadf1 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:---------------------------}| @@ -107,17 +108,16 @@ describe('Diff mode screen with 3 diffs open', function() {1: }{10: 10 }{9: BBB }│{1: }{10: 10 }{9: BBB }│{1: }{10: }{2:---------------------------}| {1: }{10: 11 }{9:>>>>>>> branch1 }│{1: }{10: 11 }{9:>>>>>>> branch1 }│{1: }{10: }{2:---------------------------}| {1: }{10: 12 } │{1: }{10: 12 } │{1: }{10: 6 } | - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| + {6:~ }│{6:~ }│{6:~ }|*2 {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:---------------------------}| @@ -127,20 +127,16 @@ describe('Diff mode screen with 3 diffs open', function() {1: }{10: 5 }{9: }{8:BBB}{9: }│{1: }{10: 7 }{9: }{8:BBB}{9: }│{1: }{10: 5 }{9: }{8:AAA}{9: }| {1: }{10: }{2:---------------------------}│{1: }{10: 8 }{4:>>>>>>> branch1 }│{1: }{10: }{2:---------------------------}| {1: }{10: 6 } │{1: }{10: 9 } │{1: }{10: 6 } | - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| + {6:~ }│{6:~ }│{6:~ }|*5 {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:---------------------------}| @@ -153,17 +149,16 @@ describe('Diff mode screen with 3 diffs open', function() {1: }{10: 5 } BBB │{1: }{10: 10 } BBB │{1: }{10: 9 } BBB | {1: }{10: }{2:---------------------------}│{1: }{10: 11 }{9:>>>>>>> branch1 }│{1: }{10: 10 }{9:>>>>>>> branch1 }| {1: }{10: 6 } │{1: }{10: 12 } │{1: }{10: 11 } | - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| + {6:~ }│{6:~ }│{6:~ }|*2 {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:---------------------------}| @@ -176,17 +171,15 @@ describe('Diff mode screen with 3 diffs open', function() {1: }{10: 5 } BBB │{1: }{10: 10 } BBB │{1: }{10: 7 } BBB | {1: }{10: }{2:---------------------------}│{1: }{10: 11 }{4:>>>>>>> branch1 }│{1: }{10: }{2:---------------------------}| {1: }{10: 6 } │{1: }{10: 12 } │{1: }{10: 8 } | - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| + {6:~ }│{6:~ }│{6:~ }|*2 {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:---------------------------}| @@ -199,14 +192,13 @@ describe('Diff mode screen with 3 diffs open', function() {1: }{10: 5 } BBB │{1: }{10: 10 } BBB │{1: }{10: 9 } BBB | {1: }{10: }{2:---------------------------}│{1: }{10: 11 }{9:>>>>>>> branch1 }│{1: }{10: 10 }{9:>>>>>>> branch1 }| {1: }{10: 6 } │{1: }{10: 12 } │{1: }{10: 11 } | - {6:~ }│{6:~ }│{6:~ }| - {6:~ }│{6:~ }│{6:~ }| + {6:~ }│{6:~ }│{6:~ }|*2 {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() @@ -238,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>') @@ -310,12 +302,7 @@ something {1: }{10: }{2:-------------------------------------------}│{1: }{10: 16 }{4:DEF }| {1: }{10: 15 }something │{1: }{10: 17 }something | {1: }{10: 16 } │{1: }{10: 18 } | - {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 }| :5,9diffget | ]]) @@ -339,9 +326,7 @@ something {1: }{10: }{2:-------------------------------------------}│{1: }{10: 13 }{4:DEF }| {1: }{10: 12 }something │{1: }{10: 14 }something | {1: }{10: 13 } │{1: }{10: 15 } | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*3 {3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }| :5,10diffget | ]]) @@ -363,15 +348,10 @@ something {1: }{10: 11 }common line │{1: }{10: 11 }common line | {1: }{10: 12 }something │{1: }{10: 12 }something | {1: }{10: 13 } │{1: }{10: 13 } | - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| - {6:~ }│{6:~ }| + {6:~ }│{6:~ }|*5 {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') @@ -776,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() @@ -804,19 +783,7 @@ 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:~ }| + {6:~ }│{6:~ }|*13 {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| :e | ]]) @@ -853,17 +820,7 @@ void testFunction () { {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:~ }| + {6:~ }│{6:~ }|*11 {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| :e | ]]) @@ -903,15 +860,7 @@ void testFunction () { {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:~ }| + {6:~ }│{6:~ }|*9 {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| :e | ]]) @@ -951,15 +900,7 @@ void testFunction () { {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:~ }| + {6:~ }│{6:~ }|*9 {7:Xtest-functional-diff-screen-1.2 }{3:Xtest-functional-diff-screen-1 }| :e | ]]) @@ -1006,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: }| @@ -1031,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: }| @@ -1056,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>') @@ -1099,20 +1043,17 @@ something {1: }{10: 10 }common line │{1: }{10: 10 }common line | {1: }{10: 11 }something │{1: }{10: 11 }something | {1: }{10: 12 } │{1: }{10: 12 } | - {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 }| :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: }| @@ -1134,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: }| @@ -1160,7 +1104,8 @@ something {3:Xtest-functional-diff-screen-1.2 }{7:Xtest-functional-diff-screen-1 [+] }| :8,10diffget | ]]) - end) + end + ) end) end) @@ -1173,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.api.nvim_buf_set_lines(0, 0, -1, false, { string.rep('a', 1000) .. 'hello' }) helpers.exec 'vnew' - helpers.curbufmeths.set_lines(0, -1, false, { string.rep('a', 1010)..'world' }) + helpers.api.nvim_buf_set_lines(0, 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) @@ -1188,12 +1133,13 @@ describe('regressions', function() for i = 0, 29 do lines[#lines + 1] = tostring(i) end - helpers.curbufmeths.set_lines(0, -1, false, lines) + helpers.api.nvim_buf_set_lines(0, 0, -1, false, lines) helpers.exec 'vnew' - helpers.curbufmeths.set_lines(0, -1, false, { '00', '29' }) + helpers.api.nvim_buf_set_lines(0, 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 }| @@ -1214,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) diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 1d11a12af4..31b1464589 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -5,9 +5,9 @@ local eval = helpers.eval local eq = helpers.eq local command = helpers.command local set_method_error = helpers.set_method_error -local meths = helpers.meths +local api = helpers.api local async_meths = helpers.async_meths -local test_build_dir = helpers.test_build_dir +local test_build_dir = helpers.paths.test_build_dir local nvim_prog = helpers.nvim_prog local exec = helpers.exec local exec_capture = helpers.exec_capture @@ -17,7 +17,7 @@ local poke_eventloop = helpers.poke_eventloop local assert_alive = helpers.assert_alive local is_os = helpers.is_os local is_ci = helpers.is_ci -local funcs = helpers.funcs +local fn = helpers.fn local skip = helpers.skip describe('ui/ext_messages', function() @@ -27,18 +27,18 @@ describe('ui/ext_messages', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true}) + screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {background = Screen.colors.Yellow}, - [8] = {foreground = Screen.colors.Red}, - [9] = {special = Screen.colors.Red, undercurl = true}, - [10] = {foreground = Screen.colors.Brown}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { background = Screen.colors.Yellow }, + [8] = { foreground = Screen.colors.Red }, + [9] = { special = Screen.colors.Red, undercurl = true }, + [10] = { foreground = Screen.colors.Brown }, }) end) after_each(function() @@ -48,25 +48,26 @@ describe('ui/ext_messages', function() it('msg_clear follows msg_show kind of confirm', function() feed('iline 1<esc>') feed(':call confirm("test")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ line ^1 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ { - content = {{"\ntest\n[O]k: ", 4}}, - kind = 'confirm', - }}} + {1:~ }|*4 + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + }, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ line ^1 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it('msg_show kind=confirm,confirm_sub,emsg,wmsg,quickfix', function() @@ -74,293 +75,335 @@ describe('ui/ext_messages', function() -- kind=confirm feed(':echo confirm("test")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | line ^2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ { - content = {{"\ntest\n[O]k: ", 4}}, - kind = 'confirm', - }}} + {1:~ }|*3 + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + }, + } feed('<cr><cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | line ^2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ { - content = { { "\ntest\n[O]k: ", 4 } }, - kind = "confirm" - }, { - content = { { "1" } }, - kind = "echo" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - } }} + {1:~ }|*3 + ]], + messages = { + { + content = { { '\ntest\n[O]k: ', 4 } }, + kind = 'confirm', + }, + { + content = { { '1' } }, + kind = 'echo', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed('<cr><cr>') -- kind=confirm_sub feed(':%s/i/X/gc<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ l{7:i}ne 1 | l{8:i}ne ^2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {reverse = true}, - [8] = {background = Screen.colors.Yellow}, - }, messages={ { - content = { { "replace with X (y/n/a/q/l/^E/^Y)?", 4 } }, - kind = "confirm_sub" - } }} + {1:~ }|*3 + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { reverse = true }, + [8] = { background = Screen.colors.Yellow }, + }, + messages = { + { + content = { { 'replace with X (y/n/a/q/l/^E/^Y)?', 4 } }, + kind = 'confirm_sub', + }, + }, + } feed('nq') -- kind=wmsg (editing readonly file) command('write ' .. fname) command('set readonly nohls') feed('G$x') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | {MATCH:.*}| - {1:~ }| - {1:~ }| - {1:~ }| - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [7] = {foreground = Screen.colors.Red}, - }, messages={ { - content = { { "W10: Warning: Changing a readonly file", 7 } }, - kind = "wmsg" - } - }} + {1:~ }|*3 + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [7] = { foreground = Screen.colors.Red }, + }, + messages = { + { + content = { { 'W10: Warning: Changing a readonly file', 7 } }, + kind = 'wmsg', + }, + }, + } -- kind=wmsg ('wrapscan' after search reaches EOF) feed('uG$/i<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ l^ine 1 | line 2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], attr_ids={ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {bold = true, reverse = true}, - [7] = {foreground = Screen.colors.Red}, - }, messages={ { - content = { { "search hit BOTTOM, continuing at TOP", 7 } }, - kind = "wmsg" - } }} + {1:~ }|*3 + ]], + attr_ids = { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, reverse = true }, + [7] = { foreground = Screen.colors.Red }, + }, + messages = { + { + content = { { 'search hit BOTTOM, continuing at TOP', 7 } }, + kind = 'wmsg', + }, + }, + } -- kind=emsg after :throw feed(':throw "foo"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ l^ine 1 | line 2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ { - content = { { "Error detected while processing :", 2 } }, - kind = "emsg" - }, { - content = { { "E605: Exception not caught: foo", 2 } }, - kind = "" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - } } + {1:~ }|*3 + ]], + messages = { + { + content = { { 'Error detected while processing :', 2 } }, + kind = 'emsg', + }, + { + content = { { 'E605: Exception not caught: foo', 2 } }, + kind = '', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, } -- kind=quickfix after :cnext feed('<c-c>') command("caddexpr [expand('%').':1:line1',expand('%').':2:line2']") feed(':cnext<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ line 1 | ^line 2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ { - content = { { "(2 of 2): line2" } }, - kind = "quickfix" - } }} + {1:~ }|*3 + ]], + messages = { + { + content = { { '(2 of 2): line2' } }, + kind = 'quickfix', + }, + }, + } end) it(':echoerr', function() feed(':echoerr "raa"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{"raa", 2}}, - kind = "echoerr", - }}} + {1:~ }|*4 + ]], + messages = { { + content = { { 'raa', 2 } }, + kind = 'echoerr', + } }, + } -- cmdline in a later input cycle clears error message feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], cmdline={{ - firstc = ":", - content = {{ "" }}, - pos = 0, - }}} - + {1:~ }|*4 + ]], + cmdline = { { + firstc = ':', + content = { { '' } }, + pos = 0, + } }, + } feed('echoerr "bork" | echoerr "fail"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "bork", 2 }}, - kind = "echoerr" - }, { - content = {{ "fail", 2 }}, - kind = "echoerr" - }, { - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}} + {1:~ }|*4 + ]], + messages = { + { + content = { { 'bork', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'fail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed(':echoerr "extrafail"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = { { "bork", 2 } }, - kind = "echoerr" - }, { - content = { { "fail", 2 } }, - kind = "echoerr" - }, { - content = { { "extrafail", 2 } }, - kind = "echoerr" - }, { - content = { { "Press ENTER or type command to continue", 4 } }, - kind = "return_prompt" - }}} + {1:~ }|*4 + ]], + messages = { + { + content = { { 'bork', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'fail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'extrafail', 2 } }, + kind = 'echoerr', + }, + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } -- cmdline without interleaving wait/display keeps the error message feed(':echoerr "problem" | let x = input("foo> ")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "problem", 2 }}, - kind = "echoerr" - }}, cmdline={{ - prompt = "foo> ", - content = {{ "" }}, - pos = 0, - }}} + {1:~ }|*4 + ]], + messages = { { + content = { { 'problem', 2 } }, + kind = 'echoerr', + } }, + cmdline = { + { + prompt = 'foo> ', + content = { { '' } }, + pos = 0, + }, + }, + } feed('solution<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } eq('solution', eval('x')) - feed(":messages<cr>") - screen:expect{grid=[[ + feed(':messages<cr>') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], msg_history={ - {kind="echoerr", content={{"raa", 2}}}, - {kind="echoerr", content={{"bork", 2}}}, - {kind="echoerr", content={{"fail", 2}}}, - {kind="echoerr", content={{"extrafail", 2}}}, - {kind="echoerr", content={{"problem", 2}}} - }, messages={{ - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}} + {1:~ }|*4 + ]], + msg_history = { + { kind = 'echoerr', content = { { 'raa', 2 } } }, + { kind = 'echoerr', content = { { 'bork', 2 } } }, + { kind = 'echoerr', content = { { 'fail', 2 } } }, + { kind = 'echoerr', content = { { 'extrafail', 2 } } }, + { kind = 'echoerr', content = { { 'problem', 2 } } }, + }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } feed '<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it(':echoerr multiline', function() exec_lua([[vim.g.multi = table.concat({ "bork", "fail" }, "\n")]]) feed(':echoerr g:multi<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "bork\nfail", 2 }}, - kind = "echoerr" - }}} + {1:~ }|*4 + ]], + messages = { { + content = { { 'bork\nfail', 2 } }, + kind = 'echoerr', + } }, + } feed(':messages<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "Press ENTER or type command to continue", 4 }}, - kind = "return_prompt" - }}, msg_history={{ - content = {{ "bork\nfail", 2 }}, - kind = "echoerr" - }}} + {1:~ }|*4 + ]], + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + msg_history = { + { + content = { { 'bork\nfail', 2 } }, + kind = 'echoerr', + }, + }, + } end) it('shortmess-=S', function() @@ -368,470 +411,533 @@ describe('ui/ext_messages', function() feed('iline 1\nline 2<esc>') feed('/line<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:^line} 1 | {7:line} 2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - {content = {{"/line W [1/2]"}}, kind = "search_count"} - }} + {1:~ }|*3 + ]], + messages = { + { content = { { '/line W [1/2]' } }, kind = 'search_count' }, + }, + } feed('n') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:line} 1 | {7:^line} 2 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - {content = {{"/line [2/2]"}}, kind = "search_count"} - }} + {1:~ }|*3 + ]], + messages = { + { content = { { '/line [2/2]' } }, kind = 'search_count' }, + }, + } end) it(':hi Group output', function() feed(':hi ErrorMsg<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - {content = {{"\nErrorMsg " }, {"xxx", 2}, {" "}, - {"ctermfg=", 5 }, { "15 " }, { "ctermbg=", 5 }, { "1 " }, - {"guifg=", 5 }, { "White " }, { "guibg=", 5 }, { "Red" }}, - kind = ""} - }} + {1:~ }|*4 + ]], + messages = { + { + content = { + { '\nErrorMsg ' }, + { 'xxx', 2 }, + { ' ' }, + { 'ctermfg=', 5 }, + { '15 ' }, + { 'ctermbg=', 5 }, + { '1 ' }, + { 'guifg=', 5 }, + { 'White ' }, + { 'guibg=', 5 }, + { 'Red' }, + }, + kind = '', + }, + }, + } end) it("doesn't crash with column adjustment #10069", function() feed(':let [x,y] = [1,2]<cr>') feed(':let x y<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - {content = {{ "x #1" }}, kind = ""}, - {content = {{ "y #2" }}, kind = ""}, - {content = {{ "Press ENTER or type command to continue", 4 }}, kind = "return_prompt"} - }} + {1:~ }|*4 + ]], + messages = { + { content = { { 'x #1' } }, kind = '' }, + { content = { { 'y #2' } }, kind = '' }, + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + } end) it('&showmode', function() command('imap <f2> <cmd>echomsg "stuff"<cr>') feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={{"-- INSERT --", 3}}} + {1:~ }|*4 + ]], + showmode = { { '-- INSERT --', 3 } }, + } feed('alphpabet<cr>alphanum<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | ^ | - {1:~ }| - {1:~ }| - ]], showmode={ { "-- INSERT --", 3 } }} + {1:~ }|*2 + ]], + showmode = { { '-- INSERT --', 3 } }, + } feed('<c-x>') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | ^ | - {1:~ }| - {1:~ }| - ]], showmode={ { "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)", 3 } }} + {1:~ }|*2 + ]], + showmode = { { '-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)', 3 } }, + } feed('<c-p>') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphanum^ | - {1:~ }| - {1:~ }| - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 1 - }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }} + {1:~ }|*2 + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 1, + }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } }, + } -- echomsg and showmode don't overwrite each other, this is the same -- as the TUI behavior with cmdheight=2 or larger. feed('<f2>') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphanum^ | - {1:~ }| - {1:~ }| - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 1 - }, messages={ { - content = { { "stuff" } }, - kind = "echomsg" - } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }} + {1:~ }|*2 + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 1, + }, + messages = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 1 of 2', 4 } }, + } feed('<c-p>') - screen:expect{grid=[[ + screen:expect { + grid = [[ alphpabet | alphanum | alphpabet^ | - {1:~ }| - {1:~ }| - ]], popupmenu={ - anchor = { 1, 2, 0 }, - items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, - pos = 0 - }, messages={ { - content = { { "stuff" } }, - kind = "echomsg" - } }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 2 of 2", 4 } }} - - feed("<esc>:messages<cr>") - screen:expect{grid=[[ + {1:~ }|*2 + ]], + popupmenu = { + anchor = { 1, 2, 0 }, + items = { { 'alphpabet', '', '', '' }, { 'alphanum', '', '', '' } }, + pos = 0, + }, + messages = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + showmode = { { '-- Keyword Local completion (^N^P) ', 3 }, { 'match 2 of 2', 4 } }, + } + + feed('<esc>:messages<cr>') + screen:expect { + grid = [[ alphpabet | alphanum | alphpabe^t | - {1:~ }| - {1:~ }| - ]], msg_history={{ - content = {{ "stuff" }}, - kind = "echomsg", - }}, messages={{ - content = {{ "Press ENTER or type command to continue", 4}}, - kind = "return_prompt" - }}} + {1:~ }|*2 + ]], + msg_history = { { + content = { { 'stuff' } }, + kind = 'echomsg', + } }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } end) it('&showmode with macro-recording message', function() feed('qq') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "recording @q", 3 } }} + {1:~ }|*4 + ]], + showmode = { { 'recording @q', 3 } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "-- INSERT --recording @q", 3 } }} + {1:~ }|*4 + ]], + showmode = { { '-- INSERT --recording @q', 3 } }, + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "recording @q", 3 } }} + {1:~ }|*4 + ]], + showmode = { { 'recording @q', 3 } }, + } feed('q') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) end) it('shows macro-recording message with &noshowmode', function() - command("set noshowmode") + command('set noshowmode') feed('qq') -- also check mode to avoid immediate success - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "recording @q", 3 } }, mode="normal"} + {1:~ }|*4 + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'normal', + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "recording @q", 3 } }, mode="insert"} + {1:~ }|*4 + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'insert', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "recording @q", 3 } }, mode="normal"} + {1:~ }|*4 + ]], + showmode = { { 'recording @q', 3 } }, + mode = 'normal', + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], mode="normal"} + {1:~ }|*4 + ]], + mode = 'normal', + } end) it('supports &showcmd and &ruler', function() command('set showcmd ruler') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], ruler={ { "0,0-1 All" } }} + {1:~ }|*4 + ]], + ruler = { { '0,0-1 All' } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], showmode={ { "-- INSERT --", 3 } }, ruler={ { "0,1 All" } }} + {1:~ }|*4 + ]], + showmode = { { '-- INSERT --', 3 } }, + ruler = { { '0,1 All' } }, + } feed('abcde<cr>12345<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | 1234^5 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], ruler={ { "2,5 All" } }} + {1:~ }|*3 + ]], + ruler = { { '2,5 All' } }, + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | 1234^5 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], showcmd={ { "d" } }, ruler={ { "2,5 All" } }} + {1:~ }|*3 + ]], + showcmd = { { 'd' } }, + ruler = { { '2,5 All' } }, + } feed('<esc>^') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], ruler={ { "2,1 All" } }} + {1:~ }|*3 + ]], + ruler = { { '2,1 All' } }, + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], showcmd={ { "d" } }, ruler={ { "2,1 All" } }} + {1:~ }|*3 + ]], + showcmd = { { 'd' } }, + ruler = { { '2,1 All' } }, + } feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^12345 | - {1:~ }| - {1:~ }| - {1:~ }| - ]], showcmd={ { "di" } }, ruler={ { "2,1 All" } }} + {1:~ }|*3 + ]], + showcmd = { { 'di' } }, + ruler = { { '2,1 All' } }, + } feed('w') - screen:expect{grid=[[ + screen:expect { + grid = [[ abcde | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - ]], ruler={ { "2,0-1 All" } }} + {1:~ }|*3 + ]], + ruler = { { '2,0-1 All' } }, + } -- when ruler is part of statusline it is not externalized. -- this will be added as part of future ext_statusline support - command("set laststatus=2") + command('set laststatus=2') screen:expect([[ abcde | ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {6:<o Name] [+] 2,0-1 All}| ]]) end) it('keeps history of message of different kinds', function() feed(':echomsg "howdy"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "howdy" }}, kind = "echomsg"} - }} + {1:~ }|*4 + ]], + messages = { { + content = { { 'howdy' } }, + kind = 'echomsg', + } }, + } -- always test a message without kind. If this one gets promoted to a -- category, add a new message without kind. feed('<c-c>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "Type :qa and press <Enter> to exit Nvim" }}, - kind = ""} - }} + {1:~ }|*4 + ]], + messages = { + { + content = { { 'Type :qa and press <Enter> to exit Nvim' } }, + kind = '', + }, + }, + } feed(':echoerr "bork"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "bork", 2 }}, kind = "echoerr"} - }} + {1:~ }|*4 + ]], + messages = { { + content = { { 'bork', 2 } }, + kind = 'echoerr', + } }, + } feed(':echo "xyz"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "xyz" }}, kind = "echo"} - }} + {1:~ }|*4 + ]], + messages = { { + content = { { 'xyz' } }, + kind = 'echo', + } }, + } feed(':call nosuchfunction()<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{ "E117: Unknown function: nosuchfunction", 2 }}, - kind = "emsg"} - }} + {1:~ }|*4 + ]], + messages = { + { + content = { { 'E117: Unknown function: nosuchfunction', 2 } }, + kind = 'emsg', + }, + }, + } feed(':messages<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], msg_history={ - {kind="echomsg", content={{"howdy"}}}, - {kind="", content={{"Type :qa and press <Enter> to exit Nvim"}}}, - {kind="echoerr", content={{"bork", 2}}}, - {kind="emsg", content={{"E117: Unknown function: nosuchfunction", 2}}} - }, messages={{ - content = {{ "Press ENTER or type command to continue", 4}}, - kind = "return_prompt" - }}} + {1:~ }|*4 + ]], + msg_history = { + { kind = 'echomsg', content = { { 'howdy' } } }, + { kind = '', content = { { 'Type :qa and press <Enter> to exit Nvim' } } }, + { kind = 'echoerr', content = { { 'bork', 2 } } }, + { kind = 'emsg', content = { { 'E117: Unknown function: nosuchfunction', 2 } } }, + }, + messages = { + { + content = { { 'Press ENTER or type command to continue', 4 } }, + kind = 'return_prompt', + }, + }, + } end) it('implies ext_cmdline and ignores cmdheight', function() eq(0, eval('&cmdheight')) feed(':set cmdheight=1') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], cmdline={{ - content = { { "set cmdheight=1" } }, - firstc = ":", - pos = 15 } - }} + {1:~ }|*4 + ]], + cmdline = { + { + content = { { 'set cmdheight=1' } }, + firstc = ':', + pos = 15, + }, + }, + } feed('<cr>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) eq(0, eval('&cmdheight')) feed(':set cmdheight=0') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], cmdline={{ - content = { { "set cmdheight=0" } }, - firstc = ":", - pos = 15 } - }} + {1:~ }|*4 + ]], + cmdline = { + { + content = { { 'set cmdheight=0' } }, + firstc = ':', + pos = 15, + }, + }, + } feed('<cr>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) eq(0, eval('&cmdheight')) end) it('supports multiline messages from lua', function() feed(':lua error("such\\nmultiline\\nerror")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{[[E5108: Error executing lua [string ":lua"]:1: such + {1:~ }|*4 + ]], + messages = { + { + content = { + { + [[E5108: Error executing lua [string ":lua"]:1: such multiline error stack traceback: [C]: in function 'error' - [string ":lua"]:1: in main chunk]], 2}}, - kind = "lua_error", - }}} + [string ":lua"]:1: in main chunk]], + 2, + }, + }, + kind = 'lua_error', + }, + }, + } end) it('supports multiline messages from rpc', function() feed(':call rpcrequest(1, "test_method")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{"Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2}}, - kind = "rpc_error" - }}, request_cb=function (name) - if name == "test_method" then - set_method_error("complete\nerror\n\nmessage") - end - end} + {1:~ }|*4 + ]], + messages = { + { + content = { + { "Error invoking 'test_method' on channel 1:\ncomplete\nerror\n\nmessage", 2 }, + }, + kind = 'rpc_error', + }, + }, + request_cb = function(name) + if name == 'test_method' then + set_method_error('complete\nerror\n\nmessage') + end + end, + } end) it('supports multiline messages for :map', function() @@ -841,10 +947,18 @@ stack traceback: command('nnoremap j k') feed(':map<cr>') - screen:expect{messages={{ - content = {{ "\nn Q @@\nn Y y$\nn j " }, { "*", 5 }, { " k" }}, - kind = '' - }}} + screen:expect { + messages = { + { + content = { + { '\nn Q @@\nn Y y$\nn j ' }, + { '*', 5 }, + { ' k' }, + }, + kind = '', + }, + }, + } end) it('wildmode=list', function() @@ -853,23 +967,23 @@ stack traceback: command('set wildmenu wildmode=list') feed(':set wildm<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={{ - content = {{'wildmenu wildmode'}}, + {1:~ }|*6 + ]], + messages = { { + content = { { 'wildmenu wildmode' } }, kind = '', - }}, - cmdline={{ - firstc = ':', - content = {{ 'set wildm' }}, - pos = 9, - }}} + } }, + cmdline = { + { + firstc = ':', + content = { { 'set wildm' } }, + pos = 9, + }, + }, + } end) it('hides prompt_for_number messages', function() @@ -877,89 +991,110 @@ stack traceback: feed('ihelllo<esc>') feed('z=') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:helllo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {1:^~ }| - ]], messages={ - {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""} - }} + ]], + messages = { + { + content = { + { + 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ', + }, + }, + kind = '', + }, + }, + } feed('1') - screen:expect{grid=[[ + screen:expect { + grid = [[ {9:helllo} | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {1:^~ }| - ]], messages={ - {content = { { 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ' } }, kind = ""}, - { content = { { "1" } }, kind = "" } - }} + ]], + messages = { + { + content = { + { + 'Change "helllo" to:\n 1 "Hello"\n 2 "Hallo"\n 3 "Hullo"\nType number and <Enter> or click with the mouse (q or empty cancels): ', + }, + }, + kind = '', + }, + { content = { { '1' } }, kind = '' }, + }, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^Hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {}) - screen:expect{grid=[[ + async_meths.nvim_echo( + { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, + true, + {} + ) + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" } - }} + {1:~ }|*4 + ]], + messages = { + { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' }, + }, + } feed ':ls<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = "" } - }} + {1:~ }|*4 + ]], + messages = { + { content = { { '\n 1 %a "[No Name]" line 1' } }, kind = '' }, + }, + } feed ':messages<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]], messages={ - { content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } - }, msg_history={ - { content = { { "wow, ", 7 }, { "such\n\nvery ", 2 }, { "color", 10 } }, kind = "echomsg" } - }} + {1:~ }|*4 + ]], + messages = { + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + msg_history = { + { content = { { 'wow, ', 7 }, { 'such\n\nvery ', 2 }, { 'color', 10 } }, kind = 'echomsg' }, + }, + } feed '<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } end) it('does not truncate messages', function() - command('write '.. fname) - screen:expect({messages={ - {content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = "" } - }}) + command('write ' .. fname) + screen:expect({ + messages = { + { content = { { string.format('"%s" [New] 0L, 0B written', fname) } }, kind = '' }, + }, + }) end) end) @@ -968,26 +1103,27 @@ describe('ui/builtin messages', function() before_each(function() clear() screen = Screen.new(60, 7) - screen:attach({rgb=true, ext_popupmenu=true}) - screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}; - [3] = {bold = true, reverse = true}; - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}; - [5] = {foreground = Screen.colors.Blue1}; - [6] = {bold = true, foreground = Screen.colors.Magenta}; - [7] = {background = Screen.colors.Grey20}; - [8] = {reverse = true}; - [9] = {background = Screen.colors.LightRed}; - [10] = {background = Screen.colors.Yellow}; - [11] = {foreground = Screen.colors.Brown}; + screen:attach({ rgb = true, ext_popupmenu = true }) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true, reverse = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { bold = true, foreground = Screen.colors.Magenta }, + [7] = { background = Screen.colors.Grey20 }, + [8] = { reverse = true }, + [9] = { background = Screen.colors.LightRed }, + [10] = { background = Screen.colors.Yellow }, + [11] = { foreground = Screen.colors.Brown }, } end) it('supports multiline messages from rpc', function() feed(':call rpcrequest(1, "test_method")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3: }| {2:Error invoking 'test_method' on channel 1:} | {2:complete} | @@ -995,20 +1131,21 @@ describe('ui/builtin messages', function() | {2:message} | {4:Press ENTER or type command to continue}^ | - ]], request_cb=function (name) - if name == "test_method" then - set_method_error("complete\nerror\n\nmessage") - end - end} + ]], + request_cb = function(name) + if name == 'test_method' then + set_method_error('complete\nerror\n\nmessage') + end + end, + } end) it(':hi Group output', function() - screen:try_resize(70,7) + screen:try_resize(70, 7) feed(':hi ErrorMsg<cr>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| :hi ErrorMsg | ErrorMsg {2:xxx} {5:ctermfg=}15 {5:ctermbg=}1 {5:guifg=}White {5:guibg=}Red | @@ -1016,7 +1153,7 @@ describe('ui/builtin messages', function() ]]) feed('<cr>') - screen:try_resize(30,7) + screen:try_resize(30, 7) feed(':hi ErrorMsg<cr>') screen:expect([[ :hi ErrorMsg | @@ -1030,14 +1167,13 @@ describe('ui/builtin messages', function() feed('<cr>') -- screen size doesn't affect internal output #10285 - eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', - exec_capture("hi ErrorMsg")) + eq('ErrorMsg xxx ctermfg=15 ctermbg=1 guifg=White guibg=Red', exec_capture('hi ErrorMsg')) end) it(':syntax list langGroup output', function() - command("syntax on") - command("set syntax=vim") - screen:try_resize(110,7) + command('syntax on') + command('set syntax=vim') + screen:try_resize(110, 7) feed(':syntax list vimComment<cr>') screen:expect([[ {6:--- Syntax items ---} | @@ -1050,7 +1186,7 @@ describe('ui/builtin messages', function() ]]) feed('<cr>') - screen:try_resize(55,7) + screen:try_resize(55, 7) feed(':syntax list vimComment<cr>') screen:expect([[ | @@ -1065,12 +1201,14 @@ describe('ui/builtin messages', function() -- ignore final whitespace inside string -- luacheck: push ignore - eq([[--- Syntax items --- + eq( + [[--- Syntax items --- vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vimCommentGroup,vimCommentString match /\<endif\s\+".*$/ms=s+5,lc=5 contains=@vimCommentGroup,vimCommentString match /\<else\s\+".*$/ms=s+4,lc=4 contains=@vimCommentGroup,vimCommentString links to Comment]], - exec_capture('syntax list vimComment')) + exec_capture('syntax list vimComment') + ) -- luacheck: pop end) @@ -1090,103 +1228,91 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim endfunc ]]) feed(':call T1()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T1 | - ]]} + ]], + } feed(':call T2()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T2 | - ]]} + ]], + } feed(':call T3()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 message T3 | - ]]} + ]], + } end) it('supports ruler with laststatus=0', function() - command("set ruler laststatus=0") - screen:expect{grid=[[ + command('set ruler laststatus=0') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 0,0-1 All | - ]]} + ]], + } - command("hi MsgArea guibg=#333333") - screen:expect{grid=[[ + command('hi MsgArea guibg=#333333') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {7: 0,0-1 All }| - ]]} + ]], + } - command("set rulerformat=%15(%c%V\\ %p%%%)") - screen:expect{grid=[[ + command('set rulerformat=%15(%c%V\\ %p%%%)') + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {7: 0,0-1 100% }| - ]]} + ]], + } end) it('supports echo with CRLF line separators', function() feed(':echo "line 1\\r\\nline 2"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3: }| line 1 | line 2 | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed('<cr>:echo "abc\\rz"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 zbc | - ]]} + ]], + } end) it('redraws UPD_NOT_VALID correctly after message', function() -- edge case: only one window was set UPD_NOT_VALID. Original report -- used :make, but fake it using one command to set the current -- window UPD_NOT_VALID and another to show a long message. - command("set more") + command('set more') feed(':new<cr><c-w><c-w>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -1194,10 +1320,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| :new | - ]]} + ]], + } feed(':set colorcolumn=10 | digraphs<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ :set colorcolumn=10 | digraphs | NU {5:^@} 10 SH {5:^A} 1 SX {5:^B} 2 EX {5:^C} 3 | ET {5:^D} 4 EQ {5:^E} 5 AK {5:^F} 6 BL {5:^G} 7 | @@ -1205,10 +1333,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim FF {5:^L} 12 CR {5:^M} 13 SO {5:^N} 14 SI {5:^O} 15 | DL {5:^P} 16 D1 {5:^Q} 17 D2 {5:^R} 18 D3 {5:^S} 19 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -1216,11 +1346,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| | - ]]} + ]], + } -- edge case: just covers statusline feed(':set colorcolumn=5 | lua error("x\\n\\nx")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string ":lua"]:1: x} | | {2:x} | @@ -1228,10 +1360,12 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {2: [C]: in function 'error'} | {2: [string ":lua"]:1: in main chunk} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {8:[No Name] }| @@ -1239,35 +1373,43 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {1:~ }| {3:[No Name] }| | - ]]} + ]], + } -- edge case: just covers lowest window line feed(':set colorcolumn=5 | lua error("x\\n\\n\\nx")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string ":lua"]:1: x} | - | - | + |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | {4:-- More --}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ - | - | + screen:expect { + grid = [[ + |*2 {2:x} | {2:stack traceback:} | {2: [C]: in function 'error'} | {2: [string ":lua"]:1: in main chunk} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end) it('supports nvim_echo messages with multiple attrs', function() - async_meths.echo({{'wow, ',"Search"}, {"such\n\nvery ", "ErrorMsg"}, {"color", "LineNr"}}, true, {}) - screen:expect{grid=[[ + async_meths.nvim_echo( + { { 'wow, ', 'Search' }, { 'such\n\nvery ', 'ErrorMsg' }, { 'color', 'LineNr' } }, + true, + {} + ) + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1275,21 +1417,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | {2:very }{11:color} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed '<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | - ]]} + ]], + } feed ':messages<cr>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1297,12 +1439,13 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim | {2:very }{11:color} | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end) it('prints lines in Ex mode correctly with a burst of carriage returns #19341', function() command('set number') - meths.buf_set_lines(0, 0, 0, true, {'aaa', 'bbb', 'ccc'}) + api.nvim_buf_set_lines(0, 0, 0, true, { 'aaa', 'bbb', 'ccc' }) feed('gggQ<CR><CR>1<CR><CR>vi') screen:expect([[ Entering Ex mode. Type "visual" to go to Normal mode. | @@ -1319,8 +1462,7 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim {11: 2 }^bbb | {11: 3 }ccc | {11: 4 } | - {1:~ }| - {1:~ }| + {1:~ }|*2 | ]]) end) @@ -1339,19 +1481,21 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim endfunc ]]):format(to_block)) feed(':call PrintAndWait()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3: }| aaa | bbb^ | - ]], timeout=timeout} + ]], + timeout = timeout, + } if type(to_unblock) == 'string' then feed(to_unblock) end - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {3: }| @@ -1359,7 +1503,8 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim bbb | ccc | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } end it('getchar()', function() @@ -1375,17 +1520,18 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim end) end) - it('consecutive calls to win_move_statusline() work after multiline message #21014',function() - async_meths.exec([[ + it('consecutive calls to win_move_statusline() work after multiline message #21014', function() + async_meths.nvim_exec( + [[ echo "\n" call win_move_statusline(0, -4) call win_move_statusline(0, 4) - ]], false) + ]], + false + ) screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {3: }| | {4:Press ENTER or type command to continue}^ | @@ -1393,14 +1539,10 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim feed('<CR>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) it('using nvim_echo in VimResized does not cause hit-enter prompt #26139', function() @@ -1408,12 +1550,27 @@ vimComment xxx match /\s"[^\-:.%#=*].*$/ms=s+1,lc=1 excludenl contains=@vim screen:try_resize(60, 5) screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) - eq({ mode = 'n', blocking = false }, meths.get_mode()) + eq({ mode = 'n', blocking = false }, api.nvim_get_mode()) + end) + + it('bottom of screen is cleared after increasing &cmdheight #20360', function() + command('set laststatus=2') + screen:expect([[ + ^ | + {1:~ }|*4 + {3:[No Name] }| + | + ]]) + command('set cmdheight=4') + screen:expect([[ + ^ | + {1:~ }| + {3:[No Name] }| + |*4 + ]]) end) end) @@ -1432,17 +1589,17 @@ describe('ui/ext_messages', function() local screen before_each(function() - clear{args_rm={'--headless'}, args={"--cmd", "set shortmess-=I"}} + clear { args_rm = { '--headless' }, args = { '--cmd', 'set shortmess-=I' } } screen = Screen.new(80, 24) - screen:attach({rgb=true, ext_messages=true, ext_popupmenu=true}) + screen:attach({ rgb = true, ext_messages = true, ext_popupmenu = true }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {bold = true}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {foreground = Screen.colors.Blue1}, - [6] = {reverse = true}, - [7] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { bold = true }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { foreground = Screen.colors.Blue1 }, + [6] = { reverse = true }, + [7] = { bold = true, reverse = true }, }) end) @@ -1451,10 +1608,7 @@ describe('ui/ext_messages', function() -- Note parts of it depends on version or is indeterministic. We ignore those parts. screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {MATCH:.*}| {1:~ }| {1:~ }Nvim is open source and freely distributable{1: }| @@ -1467,50 +1621,21 @@ describe('ui/ext_messages', function() {1:~ }| {1:~{MATCH: +}}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+}{1:{MATCH: +}}| {1:~ }| - {MATCH:.*}| - {MATCH:.*}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {MATCH:.*}|*2 + {1:~ }|*5 ]]) - feed("<c-l>") + feed('<c-l>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*23 ]]) - feed(":intro<cr>") - screen:expect{grid=[[ + feed(':intro<cr>') + screen:expect { + grid = [[ ^ | - | - | - | - | + |*4 {MATCH:.*}| | Nvim is open source and freely distributable | @@ -1523,116 +1648,68 @@ describe('ui/ext_messages', function() | {MATCH: +}type :help news{5:<Enter>} to see changes in v{MATCH:%d+%.%d+ +}| | - {MATCH:.*}| - {MATCH:.*}| - | - | - | - | - | - ]], messages={ - {content = { { "Press ENTER or type command to continue", 4 } }, kind = "return_prompt" } - }} + {MATCH:.*}|*2 + |*5 + ]], + messages = { + { content = { { 'Press ENTER or type command to continue', 4 } }, kind = 'return_prompt' }, + }, + } end) it('supports global statusline', function() - feed(":set laststatus=3<cr>") - feed(":sp<cr>") - feed(":set cmdheight<cr>") - screen:expect({grid=[[ + feed(':set laststatus=3<cr>') + feed(':sp<cr>') + feed(':set cmdheight<cr>') + screen:expect({ + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 {7:[No Name] }| - ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' cmdheight=0' } }, kind = '' }, + }, + }) - feed("<c-w>+") - feed(":set laststatus<cr>") - screen:expect({grid=[[ + feed('<c-w>+') + feed(':set laststatus<cr>') + screen:expect({ + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*9 {7:[No Name] }| - ]], messages={ - {content = { { " laststatus=3" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' laststatus=3' } }, kind = '' }, + }, + }) - feed(":set mouse=a<cr>") - meths.input_mouse('left', 'press', '', 0, 12, 10) + feed(':set mouse=a<cr>') + api.nvim_input_mouse('left', 'press', '', 0, 12, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 11, 10) - feed("<c-l>") - feed(":set cmdheight<cr>") - screen:expect({grid=[[ + api.nvim_input_mouse('left', 'drag', '', 0, 11, 10) + feed('<c-l>') + feed(':set cmdheight<cr>') + screen:expect({ + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ────────────────────────────────────────────────────────────────────────────────| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 {7:[No Name] }| - ]], messages={ - {content = { { " cmdheight=0" } }, kind = "" } - }}) + ]], + messages = { + { content = { { ' cmdheight=0' } }, kind = '' }, + }, + }) end) end) @@ -1640,9 +1717,9 @@ describe('ui/msg_puts_printf', function() it('output multibyte characters correctly', function() local screen local cmd = '' - local locale_dir = test_build_dir..'/share/locale/ja/LC_MESSAGES' + local locale_dir = test_build_dir .. '/share/locale/ja/LC_MESSAGES' - clear({env={LANG='ja_JP.UTF-8'}}) + clear({ env = { LANG = 'ja_JP.UTF-8' } }) screen = Screen.new(25, 5) screen:attach() @@ -1654,7 +1731,7 @@ describe('ui/msg_puts_printf', function() cmd = 'chcp 932 > NULL & ' end else - if (exc_exec('lang ja_JP.UTF-8') ~= 0) then + if exc_exec('lang ja_JP.UTF-8') ~= 0 then pending('Locale ja_JP.UTF-8 not supported', function() end) return elseif is_ci() then @@ -1664,11 +1741,13 @@ describe('ui/msg_puts_printf', function() end end - os.execute('cmake -E make_directory '..locale_dir) - os.execute('cmake -E copy '..test_build_dir..'/src/nvim/po/ja.mo '..locale_dir..'/nvim.mo') + os.execute('cmake -E make_directory ' .. locale_dir) + os.execute( + 'cmake -E copy ' .. test_build_dir .. '/src/nvim/po/ja.mo ' .. locale_dir .. '/nvim.mo' + ) - cmd = cmd..'"'..nvim_prog..'" -u NONE -i NONE -Es -V1' - command([[call termopen(']]..cmd..[[')]]) + cmd = cmd .. '"' .. nvim_prog .. '" -u NONE -i NONE -Es -V1' + command([[call termopen(']] .. cmd .. [[')]]) screen:expect([[ ^Exモードに入ります. ノー | マルモードに戻るには"visu| @@ -1677,7 +1756,7 @@ describe('ui/msg_puts_printf', function() | ]]) - os.execute('cmake -E remove_directory '..test_build_dir..'/share') + os.execute('cmake -E remove_directory ' .. test_build_dir .. '/share') end) end) @@ -1689,92 +1768,108 @@ describe('pager', function() screen = Screen.new(35, 8) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [3] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red, special=Screen.colors.Yellow}, - [4] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [5] = {special = Screen.colors.Yellow}, - [6] = {special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4}, - [7] = {foreground = Screen.colors.Grey0, background = Screen.colors.Grey100}, - [8] = {foreground = Screen.colors.Gray90, background = Screen.colors.Grey100}, - [9] = {foreground = tonumber('0x00000c'), background = Screen.colors.Grey100}, - [10] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff')}, - [11] = {background = Screen.colors.Grey100, bold = true, foreground = tonumber ('0x2b8452')}, - [12] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [3] = { + foreground = Screen.colors.Grey100, + background = Screen.colors.Red, + special = Screen.colors.Yellow, + }, + [4] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [5] = { special = Screen.colors.Yellow }, + [6] = { special = Screen.colors.Yellow, bold = true, foreground = Screen.colors.SeaGreen4 }, + [7] = { foreground = Screen.colors.Grey0, background = Screen.colors.Grey100 }, + [8] = { foreground = Screen.colors.Gray90, background = Screen.colors.Grey100 }, + [9] = { foreground = tonumber('0x00000c'), background = Screen.colors.Grey100 }, + [10] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0xe5e5ff') }, + [11] = { background = Screen.colors.Grey100, bold = true, foreground = tonumber('0x2b8452') }, + [12] = { bold = true, reverse = true }, }) - command("set more") + command('set more') - exec_lua('_G.x = ...', [[ + exec_lua( + '_G.x = ...', + [[ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud xercitation ullamco laboris nisi ut -aliquip ex ea commodo consequat.]]) +aliquip ex ea commodo consequat.]] + ) end) it('can be quit with echon', function() - screen:try_resize(25,5) + screen:try_resize(25, 5) feed(':echon join(map(range(0, &lines*10), "v:val"), "\\n")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } end) it('can be quit with Lua #11224 #16537', function() -- NOTE: adds "4" to message history, although not displayed initially -- (triggered the more prompt). - screen:try_resize(40,5) + screen:try_resize(40, 5) feed(':lua for i=0,10 do print(i) end<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } feed(':mess<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ 0 | 1 | 2 | 3 | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ 1 | 2 | 3 | 4 | {4:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed('<cr>') end) it('handles wrapped lines with line scroll', function() feed(':lua error(_G.x)<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1783,10 +1878,12 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusmod te}| @@ -1795,10 +1892,12 @@ aliquip ex ea commodo consequat.]]) {2:a aliqua.} | {2:Ut enim ad minim veniam, quis nostr}| {4:-- More --}^ | - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1807,10 +1906,12 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusmod te}| @@ -1819,12 +1920,14 @@ aliquip ex ea commodo consequat.]]) {2:a aliqua.} | {2:Ut enim ad minim veniam, quis nostr}| {4:-- More --}^ | - ]]} + ]], + } end) it('handles wrapped lines with page scroll', function() feed(':lua error(_G.x)<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1833,9 +1936,11 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:mpor} | {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | @@ -1844,9 +1949,11 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequat.} | {4:-- More --}^ | - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -1855,9 +1962,11 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:mpor} | {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | @@ -1866,14 +1975,16 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequat.} | {4:-- More --}^ | - ]]} + ]], + } end) it('handles wrapped lines with line scroll and MsgArea highlight', function() - command("hi MsgArea guisp=Yellow") + command('hi MsgArea guisp=Yellow') feed(':lua error(_G.x)<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1882,10 +1993,12 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| {3:adipisicing elit, sed do eiusmod te}| @@ -1894,10 +2007,12 @@ aliquip ex ea commodo consequat.]]) {3:a aliqua.}{5: }| {3:Ut enim ad minim veniam, quis nostr}| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1906,10 +2021,12 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| {3:adipisicing elit, sed do eiusmod te}| @@ -1918,13 +2035,15 @@ aliquip ex ea commodo consequat.]]) {3:a aliqua.}{5: }| {3:Ut enim ad minim veniam, quis nostr}| {6:-- More --}{5:^ }| - ]]} + ]], + } end) it('handles wrapped lines with page scroll and MsgArea highlight', function() - command("hi MsgArea guisp=Yellow") + command('hi MsgArea guisp=Yellow') feed(':lua error(_G.x)<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1933,9 +2052,11 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:mpor}{5: }| {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| @@ -1944,9 +2065,11 @@ aliquip ex ea commodo consequat.]]) {3:ullamco laboris nisi ut}{5: }| {3:aliquip ex ea commodo consequat.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('u') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:E5108: Error executing lua [string }| {3:":lua"]:1: Lorem ipsum dolor sit am}| {3:et, consectetur}{5: }| @@ -1955,9 +2078,11 @@ aliquip ex ea commodo consequat.]]) {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ {3:mpor}{5: }| {3:incididunt ut labore et dolore magn}| {3:a aliqua.}{5: }| @@ -1966,52 +2091,60 @@ aliquip ex ea commodo consequat.]]) {3:ullamco laboris nisi ut}{5: }| {3:aliquip ex ea commodo consequat.}{5: }| {6:-- More --}{5:^ }| - ]]} + ]], + } end) it('preserves MsgArea highlighting after more prompt', function() - screen:try_resize(70,6) - command("hi MsgArea guisp=Yellow") - command("map x Lorem ipsum labore et dolore magna aliqua") - command("map y adipisicing elit") - command("map z incididunt ut") - command("map a labore et dolore") - command("map b ex ea commodo") - command("map xx yy") - command("map xy yz") + screen:try_resize(70, 6) + command('hi MsgArea guisp=Yellow') + command('map x Lorem ipsum labore et dolore magna aliqua') + command('map y adipisicing elit') + command('map z incididunt ut') + command('map a labore et dolore') + command('map b ex ea commodo') + command('map xx yy') + command('map xy yz') feed(':map<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: a labore et dolore }| {5: b ex ea commodo }| {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: b ex ea commodo }| {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {5: y adipisicing elit }| {6:-- More --}{5:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5: xy yz }| {5: xx yy }| {5: x Lorem ipsum labore et dolore magna aliqua }| {5: y adipisicing elit }| {5: z incididunt ut }| {6:Press ENTER or type command to continue}{5:^ }| - ]]} + ]], + } end) it('clears "-- more --" message', function() - command("hi MsgArea guisp=Yellow blend=10") + command('hi MsgArea guisp=Yellow blend=10') feed(':echon join(range(20), "\\n")<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:0}{8: }| {9:1}{10: }| {9:2}{10: }| @@ -2020,10 +2153,12 @@ aliquip ex ea commodo consequat.]]) {9:5}{10: }| {9:6}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:1}{8: }| {9:2}{10: }| {9:3}{10: }| @@ -2032,10 +2167,12 @@ aliquip ex ea commodo consequat.]]) {9:6}{10: }| {9:7}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:0}{8: }| {9:1}{10: }| {9:2}{10: }| @@ -2044,10 +2181,12 @@ aliquip ex ea commodo consequat.]]) {9:5}{10: }| {9:6}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } feed('j') - screen:expect{grid=[[ + screen:expect { + grid = [[ {7:1}{8: }| {9:2}{10: }| {9:3}{10: }| @@ -2056,52 +2195,54 @@ aliquip ex ea commodo consequat.]]) {9:6}{10: }| {9:7}{10: }| {11:--}{8: }{11:More}{8: }{11:--}{8:^ }| - ]]} + ]], + } end) it('with :!cmd does not crash on resize', function() - skip(funcs.executable('sleep') == 0, 'missing "sleep" command') + skip(fn.executable('sleep') == 0, 'missing "sleep" command') feed(':!sleep 1<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {12: }| :!sleep 1 | | - ]]} + ]], + } -- not processed while command is executing - async_meths.ui_try_resize(35, 5) + async_meths.nvim_ui_try_resize(35, 5) -- TODO(bfredl): ideally it should be processed just -- before the "press ENTER" prompt though - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {12: }| :!sleep 1 | | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | - ]]} + ]], + } end) it('can be resized', function() feed(':lua error(_G.x)<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [string }| {2:":lua"]:1: Lorem ipsum dolor sit am}| {2:et, consectetur} | @@ -2110,22 +2251,26 @@ aliquip ex ea commodo consequat.]]) {2:incididunt ut labore et dolore magn}| {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } -- responds to resize, but text is not reflown screen:try_resize(45, 5) - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:adipisicing elit, sed do eiusmod te} | {2:mpor} | {2:incididunt ut labore et dolore magn} | {2:a aliqua.} | {4:-- More --}^ | - ]]} + ]], + } -- can create empty space, as the command hasn't output the text below yet. -- text is not reflown; existing lines get cut screen:try_resize(30, 12) - screen:expect{grid=[[ + screen:expect { + grid = [[ :lua error(_G.x) | {2:E5108: Error executing lua [st}| {2:":lua"]:1: Lorem ipsum dolor s}| @@ -2134,16 +2279,16 @@ aliquip ex ea commodo consequat.]]) {2:mpore} | {2:incididunt ut labore et dolore}| {2:a aliqua.} | - | - | - | + |*3 {4:-- More --}^ | - ]]} + ]], + } -- continues in a mostly consistent state, but only new lines are -- wrapped at the new screen size. feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:E5108: Error executing lua [st}| {2:":lua"]:1: Lorem ipsum dolor s}| {2:et, consectetur} | @@ -2156,10 +2301,12 @@ aliquip ex ea commodo consequat.]]) {2:ullamco laboris nisi ut} | {2:aliquip ex ea commodo consequa}| {4:-- More --}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {2:":lua"]:1: Lorem ipsum dolor s}| {2:et, consectetur} | {2:adipisicing elit, sed do eiusm}| @@ -2172,29 +2319,24 @@ aliquip ex ea commodo consequat.]]) {2:aliquip ex ea commodo consequa}| {2:t.} | {4:-- More --}^ | - ]]} + ]], + } feed('q') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 | - ]]} + ]], + } end) it('with cmdheight=0 does not crash with g<', function() command('set cmdheight=0') feed(':ls<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {12: }| @@ -2203,22 +2345,20 @@ aliquip ex ea commodo consequat.]]) line 1 | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*7 + ]], + } feed('g<lt>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {12: }| @@ -2227,18 +2367,15 @@ aliquip ex ea commodo consequat.]]) line 1 | {4:Press ENTER or type command to cont}| {4:inue}^ | - ]]} + ]], + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*7 + ]], + } end) end) diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua index e870d6f25f..8d7fae3e91 100644 --- a/test/functional/ui/mode_spec.lua +++ b/test/functional/ui/mode_spec.lua @@ -11,39 +11,45 @@ describe('ui mode_change event', function() before_each(function() clear() screen = Screen.new(25, 4) - screen:attach({rgb= true}) - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - [2] = {bold=true}, - [3] = {reverse=true}, - [4] = {background=Screen.colors.Red, foreground=Screen.colors.White}, -- ErrorMsg + screen:attach({ rgb = true }) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.Red, foreground = Screen.colors.White }, -- ErrorMsg }) end) it('works in normal mode', function() - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="operator"} + ]], + mode = 'operator', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) -- oldtest: Test_mouse_shape_after_failed_change() @@ -52,185 +58,226 @@ describe('ui mode_change event', function() command('set nomodifiable') feed('c') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="operator"} + ]], + mode = 'operator', + } feed('c') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:E21: Cannot make changes, 'modifiable' is off} | - ]], mode="normal"} + ]], + mode = 'normal', + } end) -- oldtest: Test_mouse_shape_after_cancelling_gr() it('is restored to Normal mode after cancelling "gr"', function() feed('gr') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="replace"} + ]], + mode = 'replace', + } feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in insert mode', function() feed('i') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert"} + ]], + mode = 'insert', + } feed('word<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ wor^d | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } local matchtime = 0 - command("set showmatch") + command('set showmatch') retry(nil, nil, function() matchtime = matchtime + 1 - local screen_timeout = 1000 * matchtime -- fail faster for retry. + local screen_timeout = 1000 * matchtime -- fail faster for retry. - command("set matchtime=" .. matchtime) -- tenths of seconds + command('set matchtime=' .. matchtime) -- tenths of seconds feed('a(stuff') - screen:expect{grid=[[ + screen:expect { + grid = [[ word(stuff^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert", timeout=screen_timeout} + ]], + mode = 'insert', + timeout = screen_timeout, + } feed(')') - screen:expect{grid=[[ + screen:expect { + grid = [[ word^(stuff) | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="showmatch", timeout=screen_timeout} + ]], + mode = 'showmatch', + timeout = screen_timeout, + } - screen:expect{grid=[[ + screen:expect { + grid = [[ word(stuff)^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- INSERT --} | - ]], mode="insert", timeout=screen_timeout} + ]], + mode = 'insert', + timeout = screen_timeout, + } end) end) it('works in replace mode', function() feed('R') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- REPLACE --} | - ]], mode="replace"} + ]], + mode = 'replace', + } feed('word<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ wor^d | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in cmdline mode', function() feed(':') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^ | - ]], mode="cmdline_normal"} + ]], + mode = 'cmdline_normal', + } feed('x<left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^x | - ]], mode="cmdline_insert"} + ]], + mode = 'cmdline_insert', + } feed('<insert>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :^x | - ]], mode="cmdline_replace"} - + ]], + mode = 'cmdline_replace', + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 :x^ | - ]], mode="cmdline_normal"} + ]], + mode = 'cmdline_normal', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) it('works in visual mode', function() - insert("text") + insert('text') feed('v') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- VISUAL --} | - ]], mode="visual"} + ]], + mode = 'visual', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } command('set selection=exclusive') feed('v') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:-- VISUAL --} | - ]], mode="visual_select"} + ]], + mode = 'visual_select', + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ tex^t | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], mode="normal"} + ]], + mode = 'normal', + } end) end) - diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua index 1356ba3db8..0f30bf4471 100644 --- a/test/functional/ui/mouse_spec.lua +++ b/test/functional/ui/mouse_spec.lua @@ -1,8 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths +local clear, feed, api = helpers.clear, helpers.feed, helpers.api local insert, feed_command = helpers.insert, helpers.feed_command -local eq, funcs = helpers.eq, helpers.funcs +local eq, fn = helpers.eq, helpers.fn local poke_eventloop = helpers.poke_eventloop local command = helpers.command local exec = helpers.exec @@ -12,8 +12,8 @@ describe('ui/mouse/input', function() before_each(function() clear() - meths.set_option_value('mouse', 'a', {}) - meths.set_option_value('list', true, {}) + api.nvim_set_option_value('mouse', 'a', {}) + api.nvim_set_option_value('list', true, {}) -- NB: this is weird, but mostly irrelevant to the test -- So I didn't bother to change it command('set listchars=eol:$') @@ -21,21 +21,21 @@ describe('ui/mouse/input', function() screen = Screen.new(25, 5) screen:attach() screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {background = Screen.colors.LightGrey}, - [2] = {bold = true}, + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, + [2] = { bold = true }, [3] = { foreground = Screen.colors.Blue, background = Screen.colors.LightGrey, bold = true, }, - [4] = {reverse = true}, - [5] = {bold = true, reverse = true}, - [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [7] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [8] = {foreground = Screen.colors.Brown}, + [4] = { reverse = true }, + [5] = { bold = true, reverse = true }, + [6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [7] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [8] = { foreground = Screen.colors.Brown }, }) - command("set mousemodel=extend") + command('set mousemodel=extend') feed('itesting<cr>mouse<cr>support and selection<esc>') screen:expect([[ testing | @@ -48,13 +48,16 @@ describe('ui/mouse/input', function() it('single left click moves cursor', function() feed('<LeftMouse><2,1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ testing | mo^use | support and selection | {0:~ }| | - ]], mouse_enabled=true} + ]], + mouse_enabled = true, + } feed('<LeftMouse><0,0>') screen:expect([[ ^testing | @@ -66,15 +69,18 @@ describe('ui/mouse/input', function() end) it("in external ui works with unset 'mouse'", function() - meths.set_option_value('mouse', '', {}) + api.nvim_set_option_value('mouse', '', {}) feed('<LeftMouse><2,1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ testing | mo^use | support and selection | {0:~ }| | - ]], mouse_enabled=false} + ]], + mouse_enabled = false, + } feed('<LeftMouse><0,0>') screen:expect([[ ^testing | @@ -135,11 +141,11 @@ describe('ui/mouse/input', function() describe('tab drag', function() before_each(function() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - tab = { background=Screen.colors.LightGrey, underline=true }, - sel = { bold=true }, - fill = { reverse=true } + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + tab = { background = Screen.colors.LightGrey, underline = true }, + sel = { bold = true }, + fill = { reverse = true }, }) end) @@ -151,24 +157,21 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftDrag><14,0>') screen:expect([[ {tab: + bar }{sel: + foo }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -181,24 +184,27 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><11,0>') - screen:expect{grid=[[ + -- Prevent the case where screen:expect() with "unchanged" returns too early, + -- causing the click position to be overwritten by the next drag. + poke_eventloop() + screen:expect { + grid = [[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], unchanged=true} + ]], + unchanged = true, + } feed('<LeftDrag><6,0>') screen:expect([[ {sel: + bar }{tab: + foo }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -211,24 +217,21 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftDrag><7,0>') screen:expect([[ {tab: + bar }{sel: + foo }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -241,32 +244,31 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftDrag><4,1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], unchanged=true} + ]], + unchanged = true, + } feed('<LeftDrag><14,1>') screen:expect([[ {tab: + bar }{sel: + foo }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -279,32 +281,37 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><11,0>') - screen:expect{grid=[[ + -- Prevent the case where screen:expect() with "unchanged" returns too early, + -- causing the click position to be overwritten by the next drag. + poke_eventloop() + screen:expect { + grid = [[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], unchanged=true} + ]], + unchanged = true, + } feed('<LeftDrag><11,1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], unchanged=true} + ]], + unchanged = true, + } feed('<LeftDrag><6,1>') screen:expect([[ {sel: + bar }{tab: + foo }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -317,32 +324,31 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftDrag><4,1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]], unchanged=true} + ]], + unchanged = true, + } feed('<LeftDrag><7,1>') screen:expect([[ {tab: + bar }{sel: + foo }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -350,11 +356,11 @@ describe('ui/mouse/input', function() describe('tabline', function() before_each(function() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - tab = { background=Screen.colors.LightGrey, underline=true }, - sel = { bold=true }, - fill = { reverse=true } + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + tab = { background = Screen.colors.LightGrey, underline = true }, + sel = { bold = true }, + fill = { reverse = true }, }) end) @@ -366,22 +372,20 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><4,0>') screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| this is fo^o | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) it('left click in default tabline (position 24) closes tab', function() - meths.set_option_value('hidden', true, {}) + api.nvim_set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -389,22 +393,19 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<LeftMouse><24,0>') screen:expect([[ this is fo^o | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) it('double click in default tabline (position 4) opens new tab', function() - meths.set_option_value('hidden', true, {}) + api.nvim_set_option_value('hidden', true, {}) feed_command('%delete') insert('this is foo') feed_command('silent file foo | tabnew | file bar') @@ -412,16 +413,14 @@ describe('ui/mouse/input', function() screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| this is ba^r{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<2-LeftMouse><4,0>') screen:expect([[ {sel: Name] }{tab: + foo + bar }{fill: }{tab:X}| {0:^$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) @@ -439,8 +438,8 @@ describe('ui/mouse/input', function() return call('Test', a:000 + [2]) endfunction ]]) - meths.set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {}) - meths.set_option_value('showtabline', 2, {}) + api.nvim_set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {}) + api.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {fill:test-test2 }| testing | @@ -448,59 +447,65 @@ describe('ui/mouse/input', function() support and selectio^n | | ]]) - meths.set_var('reply', {}) + api.nvim_set_var('reply', {}) end) local check_reply = function(expected) - eq(expected, meths.get_var('reply')) - meths.set_var('reply', {}) + eq(expected, api.nvim_get_var('reply')) + api.nvim_set_var('reply', {}) end - local test_click = function(name, click_str, click_num, mouse_button, - modifiers) - + local test_click = function(name, click_str, click_num, mouse_button, modifiers) local function doit(do_click) - eq(1, funcs.has('tablineat')) - do_click(0,3) - check_reply({0, click_num, mouse_button, modifiers}) - do_click(0,4) + eq(1, fn.has('tablineat')) + do_click(0, 3) + check_reply({ 0, click_num, mouse_button, modifiers }) + do_click(0, 4) check_reply({}) - do_click(0,6) - check_reply({5, click_num, mouse_button, modifiers, 2}) - do_click(0,13) - check_reply({5, click_num, mouse_button, modifiers, 2}) + do_click(0, 6) + check_reply({ 5, click_num, mouse_button, modifiers, 2 }) + do_click(0, 13) + check_reply({ 5, click_num, mouse_button, modifiers, 2 }) end it(name .. ' works (pseudokey)', function() - doit(function (row,col) - feed(click_str .. '<' .. col .. ',' .. row .. '>') + doit(function(row, col) + feed(click_str .. '<' .. col .. ',' .. row .. '>') end) end) it(name .. ' works (nvim_input_mouse)', function() - doit(function (row,col) - local buttons = {l='left',m='middle',r='right'} + doit(function(row, col) + local buttons = { l = 'left', m = 'middle', r = 'right' } local modstr = (click_num > 1) and tostring(click_num) or '' for char in string.gmatch(modifiers, '%w') do modstr = modstr .. char .. '-' -- - not needed but should be accepted end - meths.input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col) + api.nvim_input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col) end) end) end test_click('single left click', '<LeftMouse>', 1, 'l', ' ') test_click('shifted single left click', '<S-LeftMouse>', 1, 'l', 's ') - test_click('shifted single left click with alt modifier', - '<S-A-LeftMouse>', 1, 'l', 's a ') - test_click('shifted single left click with alt and ctrl modifiers', - '<S-C-A-LeftMouse>', 1, 'l', 'sca ') + test_click('shifted single left click with alt modifier', '<S-A-LeftMouse>', 1, 'l', 's a ') + test_click( + 'shifted single left click with alt and ctrl modifiers', + '<S-C-A-LeftMouse>', + 1, + 'l', + 'sca ' + ) -- <C-RightMouse> does not work - test_click('shifted single right click with alt modifier', - '<S-A-RightMouse>', 1, 'r', 's a ') + test_click('shifted single right click with alt modifier', '<S-A-RightMouse>', 1, 'r', 's a ') -- Modifiers do not work with MiddleMouse - test_click('shifted single middle click with alt and ctrl modifiers', - '<MiddleMouse>', 1, 'm', ' ') + test_click( + 'shifted single middle click with alt and ctrl modifiers', + '<MiddleMouse>', + 1, + 'm', + ' ' + ) -- Modifiers do not work with N-*Mouse test_click('double left click', '<2-LeftMouse>', 2, 'l', ' ') test_click('triple left click', '<3-LeftMouse>', 3, 'l', ' ') @@ -552,15 +557,15 @@ describe('ui/mouse/input', function() it('left drag changes visual selection after tab click', function() screen:set_default_attr_ids({ - [0] = {bold=true, foreground=Screen.colors.Blue}, - tab = { background=Screen.colors.LightGrey, underline=true }, - sel = { bold=true }, - fill = { reverse=true }, - vis = { background=Screen.colors.LightGrey } + [0] = { bold = true, foreground = Screen.colors.Blue }, + tab = { background = Screen.colors.LightGrey, underline = true }, + sel = { bold = true }, + fill = { reverse = true }, + vis = { background = Screen.colors.LightGrey, foreground = Screen.colors.Black }, }) feed_command('silent file foo | tabnew | file bar') insert('this is bar') - feed_command('tabprevious') -- go to first tab + feed_command('tabprevious') -- go to first tab screen:expect([[ {sel: + foo }{tab: + bar }{fill: }{tab:X}| testing | @@ -568,28 +573,26 @@ describe('ui/mouse/input', function() support and selectio^n | :tabprevious | ]]) - feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab + feed('<LeftMouse><10,0><LeftRelease>') -- go to second tab helpers.poke_eventloop() feed('<LeftMouse><0,1>') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| ^this is bar{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 :tabprevious | ]]) feed('<LeftDrag><4,1>') screen:expect([[ {tab: + foo }{sel: + bar }{fill: }{tab:X}| {vis:this}^ is bar{0:$} | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sel:-- VISUAL --} | ]]) end) it('left drag changes visual selection in split layout', function() - screen:try_resize(53,14) + screen:try_resize(53, 14) command('set mouse=a') command('vsplit') command('wincmd l') @@ -597,58 +600,52 @@ describe('ui/mouse/input', function() command('enew') feed('ifoo\nbar<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ testing │testing | mouse │mouse | support and selection │support and selection | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*2 {0:~ }│{4:[No Name] [+] }| {0:~ }│foo{0:$} | {0:~ }│ba^r{0:$} | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*4 {4:[No Name] [+] }{5:[No Name] [+] }| | - ]]} + ]], + } - meths.input_mouse('left', 'press', '', 0, 6, 27) - screen:expect{grid=[[ + api.nvim_input_mouse('left', 'press', '', 0, 6, 27) + screen:expect { + grid = [[ testing │testing | mouse │mouse | support and selection │support and selection | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*2 {0:~ }│{4:[No Name] [+] }| {0:~ }│^foo{0:$} | {0:~ }│bar{0:$} | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*4 {4:[No Name] [+] }{5:[No Name] [+] }| | - ]]} - meths.input_mouse('left', 'drag', '', 0, 7, 30) + ]], + } + api.nvim_input_mouse('left', 'drag', '', 0, 7, 30) - screen:expect{grid=[[ + screen:expect { + grid = [[ testing │testing | mouse │mouse | support and selection │support and selection | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*2 {0:~ }│{4:[No Name] [+] }| {0:~ }│{1:foo}{3:$} | {0:~ }│{1:bar}{0:^$} | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*4 {4:[No Name] [+] }{5:[No Name] [+] }| {2:-- VISUAL --} | - ]]} + ]], + } end) it('two clicks will enter VISUAL and dragging selects words', function() @@ -788,7 +785,7 @@ describe('ui/mouse/input', function() end) it('ctrl + left click will search for a tag', function() - meths.set_option_value('tags', './non-existent-tags-file', {}) + api.nvim_set_option_value('tags', './non-existent-tags-file', {}) feed('<C-LeftMouse><0,0>') screen:expect([[ {6:E433: No tags file} | @@ -800,10 +797,29 @@ describe('ui/mouse/input', function() feed('<cr>') end) + it('x1 and x2 can be triggered by api', function() + api.nvim_set_var('x1_pressed', 0) + api.nvim_set_var('x1_released', 0) + api.nvim_set_var('x2_pressed', 0) + api.nvim_set_var('x2_released', 0) + command('nnoremap <X1Mouse> <Cmd>let g:x1_pressed += 1<CR>') + command('nnoremap <X1Release> <Cmd>let g:x1_released += 1<CR>') + command('nnoremap <X2Mouse> <Cmd>let g:x2_pressed += 1<CR>') + command('nnoremap <X2Release> <Cmd>let g:x2_released += 1<CR>') + api.nvim_input_mouse('x1', 'press', '', 0, 0, 0) + api.nvim_input_mouse('x1', 'release', '', 0, 0, 0) + api.nvim_input_mouse('x2', 'press', '', 0, 0, 0) + api.nvim_input_mouse('x2', 'release', '', 0, 0, 0) + eq(1, api.nvim_get_var('x1_pressed'), 'x1 pressed once') + eq(1, api.nvim_get_var('x1_released'), 'x1 released once') + eq(1, api.nvim_get_var('x2_pressed'), 'x2 pressed once') + eq(1, api.nvim_get_var('x2_released'), 'x2 released once') + end) + it('dragging vertical separator', function() screen:try_resize(45, 5) command('setlocal nowrap') - local oldwin = meths.get_current_win().id + local oldwin = api.nvim_get_current_win() command('rightbelow vnew') screen:expect([[ testing │{0:^$} | @@ -812,9 +828,9 @@ describe('ui/mouse/input', function() {4:[No Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 22) + api.nvim_input_mouse('left', 'press', '', 0, 0, 22) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 1, 12) + api.nvim_input_mouse('left', 'drag', '', 0, 1, 12) screen:expect([[ testing │{0:^$} | mouse │{0:~ }| @@ -822,7 +838,7 @@ describe('ui/mouse/input', function() {4:< Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'drag', '', 0, 2, 2) + api.nvim_input_mouse('left', 'drag', '', 0, 2, 2) screen:expect([[ te│{0:^$} | mo│{0:~ }| @@ -830,18 +846,17 @@ describe('ui/mouse/input', function() {4:< }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'release', '', 0, 2, 2) - meths.set_option_value('statuscolumn', 'foobar', { win = oldwin }) + api.nvim_input_mouse('left', 'release', '', 0, 2, 2) + api.nvim_set_option_value('statuscolumn', 'foobar', { win = oldwin }) screen:expect([[ {8:fo}│{0:^$} | - {8:fo}│{0:~ }| - {8:fo}│{0:~ }| + {8:fo}│{0:~ }|*2 {4:< }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 2) + api.nvim_input_mouse('left', 'press', '', 0, 0, 2) poke_eventloop() - meths.input_mouse('left', 'drag', '', 0, 1, 12) + api.nvim_input_mouse('left', 'drag', '', 0, 1, 12) screen:expect([[ {8:foobar}testin│{0:^$} | {8:foobar}mouse │{0:~ }| @@ -849,7 +864,7 @@ describe('ui/mouse/input', function() {4:< Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'drag', '', 0, 2, 22) + api.nvim_input_mouse('left', 'drag', '', 0, 2, 22) screen:expect([[ {8:foobar}testing │{0:^$} | {8:foobar}mouse │{0:~ }| @@ -857,7 +872,7 @@ describe('ui/mouse/input', function() {4:[No Name] [+] }{5:[No Name] }| | ]]) - meths.input_mouse('left', 'release', '', 0, 2, 22) + api.nvim_input_mouse('left', 'release', '', 0, 2, 22) end) local function wheel(use_api) @@ -892,7 +907,7 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'down', '', 0, 0, 0) + api.nvim_input_mouse('wheel', 'down', '', 0, 0, 0) else feed('<ScrollWheelDown><0,0>') end @@ -913,7 +928,7 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'up', '', 0, 0, 27) + api.nvim_input_mouse('wheel', 'up', '', 0, 0, 27) else feed('<ScrollWheelUp><27,0>') end @@ -934,8 +949,8 @@ describe('ui/mouse/input', function() :vsp | ]]) if use_api then - meths.input_mouse('wheel', 'up', '', 0, 7, 27) - meths.input_mouse('wheel', 'up', '', 0, 7, 27) + api.nvim_input_mouse('wheel', 'up', '', 0, 7, 27) + api.nvim_input_mouse('wheel', 'up', '', 0, 7, 27) else feed('<ScrollWheelUp><27,7><ScrollWheelUp>') end @@ -967,27 +982,25 @@ describe('ui/mouse/input', function() it('horizontal scrolling (pseudokey)', function() command('set sidescroll=0') - feed("<esc>:set nowrap<cr>") + feed('<esc>:set nowrap<cr>') - feed("a <esc>20Ab<esc>") + feed('a <esc>20Ab<esc>') screen:expect([[ - | - | + |*2 bbbbbbbbbbbbbbb^b | {0:~ }| | ]]) - feed("<ScrollWheelLeft><0,0>") + feed('<ScrollWheelLeft><0,0>') screen:expect([[ - | - | + |*2 n bbbbbbbbbbbbbbbbbbb^b | {0:~ }| | ]]) - feed("^<ScrollWheelRight><0,0>") + feed('^<ScrollWheelRight><0,0>') screen:expect([[ g | | @@ -999,28 +1012,26 @@ describe('ui/mouse/input', function() it('horizontal scrolling (nvim_input_mouse)', function() command('set sidescroll=0') - feed("<esc>:set nowrap<cr>") + feed('<esc>:set nowrap<cr>') - feed("a <esc>20Ab<esc>") + feed('a <esc>20Ab<esc>') screen:expect([[ - | - | + |*2 bbbbbbbbbbbbbbb^b | {0:~ }| | ]]) - meths.input_mouse('wheel', 'left', '', 0, 0, 27) + api.nvim_input_mouse('wheel', 'left', '', 0, 0, 27) screen:expect([[ - | - | + |*2 n bbbbbbbbbbbbbbbbbbb^b | {0:~ }| | ]]) - feed("^") - meths.input_mouse('wheel', 'right', '', 0, 0, 0) + feed('^') + api.nvim_input_mouse('wheel', 'right', '', 0, 0, 0) screen:expect([[ g | | @@ -1034,7 +1045,7 @@ describe('ui/mouse/input', function() command('set nowrap') command('set sidescrolloff=4') - feed("I <esc>020ib<esc>0") + feed('I <esc>020ib<esc>0') screen:expect([[ testing | mouse | @@ -1043,7 +1054,7 @@ describe('ui/mouse/input', function() | ]]) - meths.input_mouse('wheel', 'right', '', 0, 0, 27) + api.nvim_input_mouse('wheel', 'right', '', 0, 0, 27) screen:expect([[ g | | @@ -1063,7 +1074,7 @@ describe('ui/mouse/input', function() | ]]) - meths.input_mouse('wheel', 'right', '', 0, 0, 27) + api.nvim_input_mouse('wheel', 'right', '', 0, 0, 27) screen:expect([[ g | | @@ -1083,8 +1094,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1094,8 +1104,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1105,8 +1114,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1116,8 +1124,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t^3{c: } {c: }| {c:>} 私は猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1127,8 +1134,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:^>} 私は猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1138,8 +1144,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:>} 私は^猫が大好き{0:>---}{c: X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1149,11 +1154,9 @@ describe('ui/mouse/input', function() {0:>--->--->---} {c: }t2{c: } {c: }t3{c: } {c: }| {c:>} 私は猫が大好き{0:>---}{c: ^X } {0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) - end) -- level 1 - non wrapped it('(level 1) click on wrapped lines', function() @@ -1166,8 +1169,7 @@ describe('ui/mouse/input', function() t4{c: } | {c:>} 私は猫が大好き{0:>---}{c: X} | {c: } ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><0,2>') @@ -1177,8 +1179,7 @@ describe('ui/mouse/input', function() ^t4{c: } | {c:>} 私は猫が大好き{0:>---}{c: X} | {c: } ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><8,3>') @@ -1188,8 +1189,7 @@ describe('ui/mouse/input', function() t4{c: } | {c:>} 私は猫^が大好き{0:>---}{c: X} | {c: } ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><21,3>') @@ -1199,8 +1199,7 @@ describe('ui/mouse/input', function() t4{c: } | {c:>} 私は猫が大好き{0:>---}{c: ^X} | {c: } ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><4,4>') @@ -1210,12 +1209,10 @@ describe('ui/mouse/input', function() t4{c: } | {c:>} 私は猫が大好き{0:>---}{c: X} | {c: } ✨^🐈✨ | - | - | + |*2 ]]) end) -- level 1 - wrapped - it('(level 2) click on non-wrapped lines', function() feed_command('let &conceallevel=2', 'echo') @@ -1225,8 +1222,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1236,8 +1232,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} ^t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1247,19 +1242,17 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t^3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) - feed('<esc><LeftMouse><0,2>') -- Weirdness + feed('<esc><LeftMouse><0,2>') -- Weirdness screen:expect([[ Section{0:>>--->--->---}t1 | {0:>--->--->---} t2 t3 t4 | {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1269,8 +1262,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1280,8 +1272,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) -- level 2 - non wrapped @@ -1295,8 +1286,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) @@ -1306,8 +1296,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} ^t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) @@ -1317,19 +1306,17 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t^3 t4 | {c:>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) - feed('<LeftMouse><0,2>') -- Weirdness + feed('<LeftMouse><0,2>') -- Weirdness screen:expect([[ Section{0:>>--->--->---}t1 | {0:>--->--->---} t2 t3 t4 | {c:^>} 私は猫が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) @@ -1339,8 +1326,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫^が大好き{0:>---}{c:X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) @@ -1350,8 +1336,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | {c:>} 私は猫が大好き{0:>---}{c:^X} ✨{0:>}| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {sm:-- INSERT --} | ]]) end) -- level 2 - non wrapped (insert mode) @@ -1366,8 +1351,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><14,1>') @@ -1377,8 +1361,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><18,1>') @@ -1388,8 +1371,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) -- NOTE: The click would ideally be on the 't' in 't4', but wrapping @@ -1405,8 +1387,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><1,2>') @@ -1416,8 +1397,7 @@ describe('ui/mouse/input', function() t^4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><0,3>') @@ -1427,8 +1407,7 @@ describe('ui/mouse/input', function() t4 | {c:^>} 私は猫が大好き{0:>---}{c:X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><20,3>') @@ -1438,8 +1417,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:^X} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><1,4>') @@ -1449,8 +1427,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ^✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><5,4>') @@ -1460,8 +1437,7 @@ describe('ui/mouse/input', function() t4 | {c:>} 私は猫が大好き{0:>---}{c:X} | ✨🐈^✨ | - | - | + |*2 ]]) end) -- level 2 - wrapped @@ -1474,8 +1450,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | ^ 私は猫が大好き{0:>----} ✨🐈| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1485,8 +1460,7 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | ^私は猫が大好き{0:>----} ✨🐈| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) @@ -1496,20 +1470,18 @@ describe('ui/mouse/input', function() {0:>--->--->---} t2 t3 t4 | 私は猫が大好^き{0:>----} ✨🐈| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) feed('<esc><LeftMouse><20,2>') - feed('zH') -- FIXME: unnecessary horizontal scrolling + feed('zH') -- FIXME: unnecessary horizontal scrolling screen:expect([[ Section{0:>>--->--->---}t1 | {0:>--->--->---} t2 t3 t4 | 私は猫が大好き{0:>----}^ ✨🐈| | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) -- level 3 - non wrapped @@ -1524,8 +1496,7 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><18,1>') @@ -1535,8 +1506,7 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><1,2>') @@ -1546,8 +1516,7 @@ describe('ui/mouse/input', function() t^4 | 私は猫が大好き{0:>----} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><0,3>') @@ -1557,8 +1526,7 @@ describe('ui/mouse/input', function() t4 | ^ 私は猫が大好き{0:>----} | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><20,3>') @@ -1568,8 +1536,7 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----}^ | ✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><1,4>') @@ -1579,8 +1546,7 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----} | ^✨🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><3,4>') @@ -1590,8 +1556,7 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----} | ✨^🐈✨ | - | - | + |*2 ]]) feed('<esc><LeftMouse><5,4>') @@ -1601,10 +1566,8 @@ describe('ui/mouse/input', function() t4 | 私は猫が大好き{0:>----} | ✨🐈^✨ | - | - | + |*2 ]]) - end) -- level 3 - wrapped end @@ -1648,66 +1611,65 @@ describe('ui/mouse/input', function() describe('(matchadd())', function() before_each(function() - funcs.matchadd('Conceal', [[\*]]) - funcs.matchadd('Conceal', [[cats]], 10, -1, { conceal = 'X' }) - funcs.matchadd('Conceal', [[\n\@<=x]], 10, -1, { conceal = '>' }) + fn.matchadd('Conceal', [[\*]]) + fn.matchadd('Conceal', [[cats]], 10, -1, { conceal = 'X' }) + fn.matchadd('Conceal', [[\n\@<=x]], 10, -1, { conceal = '>' }) end) test_mouse_click_conceal() end) describe('(extmarks)', function() before_each(function() - local ns = meths.create_namespace('conceal') - meths.buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) - meths.buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' }) - meths.buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' }) - meths.buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' }) - meths.buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' }) + local ns = api.nvim_create_namespace('conceal') + api.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' }) + api.nvim_buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' }) + api.nvim_buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' }) end) test_mouse_click_conceal() end) - end) it('getmousepos() works correctly', function() - local winwidth = meths.get_option_value('winwidth', {}) + local winwidth = api.nvim_get_option_value('winwidth', {}) -- Set winwidth=1 so that window sizes don't change. - meths.set_option_value('winwidth', 1, {}) + api.nvim_set_option_value('winwidth', 1, {}) command('tabedit') - local tabpage = meths.get_current_tabpage() + local tabpage = api.nvim_get_current_tabpage() insert('hello') command('vsplit') local opts = { - relative='editor', - width=12, - height=1, - col=8, - row=1, - anchor='NW', - style='minimal', - border='single', - focusable=1 + relative = 'editor', + width = 12, + height = 1, + col = 8, + row = 1, + anchor = 'NW', + style = 'minimal', + border = 'single', + focusable = 1, } - local float = meths.open_win(meths.get_current_buf(), false, opts) + local float = api.nvim_open_win(api.nvim_get_current_buf(), false, opts) command('redraw') - local lines = meths.get_option_value('lines', {}) - local columns = meths.get_option_value('columns', {}) + local lines = api.nvim_get_option_value('lines', {}) + local columns = api.nvim_get_option_value('columns', {}) -- Test that screenrow and screencol are set properly for all positions. for row = 0, lines - 1 do for col = 0, columns - 1 do -- Skip the X button that would close the tab. if row ~= 0 or col ~= columns - 1 then - meths.input_mouse('left', 'press', '', 0, row, col) - meths.set_current_tabpage(tabpage) - local mousepos = funcs.getmousepos() + api.nvim_input_mouse('left', 'press', '', 0, row, col) + api.nvim_set_current_tabpage(tabpage) + local mousepos = fn.getmousepos() eq(row + 1, mousepos.screenrow) eq(col + 1, mousepos.screencol) -- All other values should be 0 when clicking on the command line. @@ -1730,20 +1692,24 @@ describe('ui/mouse/input', function() for win_col = 0, opts.width + 1 do local row = win_row + opts.row local col = win_col + opts.col - meths.input_mouse('left', 'press', '', 0, row, col) - local mousepos = funcs.getmousepos() - eq(float.id, mousepos.winid) + api.nvim_input_mouse('left', 'press', '', 0, row, col) + local mousepos = fn.getmousepos() + eq(float, mousepos.winid) eq(win_row + 1, mousepos.winrow) eq(win_col + 1, mousepos.wincol) local line = 0 local column = 0 local coladd = 0 - if win_row > 0 and win_row < opts.height + 1 - and win_col > 0 and win_col < opts.width + 1 then + if + win_row > 0 + and win_row < opts.height + 1 + and win_col > 0 + and win_col < opts.width + 1 + then -- Because of border, win_row and win_col don't need to be -- incremented by 1. - line = math.min(win_row, funcs.line('$')) - column = math.min(win_col, #funcs.getline(line) + 1) + line = math.min(win_row, fn.line('$')) + column = math.min(win_col, #fn.getline(line) + 1) coladd = win_col - column end eq(line, mousepos.line) @@ -1755,19 +1721,19 @@ describe('ui/mouse/input', function() -- Test that mouse position values are properly set for the floating -- window, after removing the border. opts.border = 'none' - meths.win_set_config(float, opts) + api.nvim_win_set_config(float, opts) command('redraw') for win_row = 0, opts.height - 1 do for win_col = 0, opts.width - 1 do local row = win_row + opts.row local col = win_col + opts.col - meths.input_mouse('left', 'press', '', 0, row, col) - local mousepos = funcs.getmousepos() - eq(float.id, mousepos.winid) + api.nvim_input_mouse('left', 'press', '', 0, row, col) + local mousepos = fn.getmousepos() + eq(float, mousepos.winid) eq(win_row + 1, mousepos.winrow) eq(win_col + 1, mousepos.wincol) - local line = math.min(win_row + 1, funcs.line('$')) - local column = math.min(win_col + 1, #funcs.getline(line) + 1) + local line = math.min(win_row + 1, fn.line('$')) + local column = math.min(win_col + 1, #fn.getline(line) + 1) local coladd = win_col + 1 - column eq(line, mousepos.line) eq(column, mousepos.column) @@ -1780,20 +1746,20 @@ describe('ui/mouse/input', function() -- that getmousepos() does not consider unfocusable floats. (see discussion -- in PR #14937 for details). opts.focusable = false - meths.win_set_config(float, opts) + api.nvim_win_set_config(float, opts) command('redraw') for nr = 1, 2 do - for win_row = 0, funcs.winheight(nr) - 1 do - for win_col = 0, funcs.winwidth(nr) - 1 do - local row = win_row + funcs.win_screenpos(nr)[1] - 1 - local col = win_col + funcs.win_screenpos(nr)[2] - 1 - meths.input_mouse('left', 'press', '', 0, row, col) - local mousepos = funcs.getmousepos() - eq(funcs.win_getid(nr), mousepos.winid) + for win_row = 0, fn.winheight(nr) - 1 do + for win_col = 0, fn.winwidth(nr) - 1 do + local row = win_row + fn.win_screenpos(nr)[1] - 1 + local col = win_col + fn.win_screenpos(nr)[2] - 1 + api.nvim_input_mouse('left', 'press', '', 0, row, col) + local mousepos = fn.getmousepos() + eq(fn.win_getid(nr), mousepos.winid) eq(win_row + 1, mousepos.winrow) eq(win_col + 1, mousepos.wincol) - local line = math.min(win_row + 1, funcs.line('$')) - local column = math.min(win_col + 1, #funcs.getline(line) + 1) + local line = math.min(win_row + 1, fn.line('$')) + local column = math.min(win_col + 1, #fn.getline(line) + 1) local coladd = win_col + 1 - column eq(line, mousepos.line) eq(column, mousepos.column) @@ -1804,34 +1770,34 @@ describe('ui/mouse/input', function() -- Restore state and release mouse. command('tabclose!') - meths.set_option_value('winwidth', winwidth, {}) - meths.input_mouse('left', 'release', '', 0, 0, 0) + api.nvim_set_option_value('winwidth', winwidth, {}) + api.nvim_input_mouse('left', 'release', '', 0, 0, 0) end) it('scroll keys are not translated into multiclicks and can be mapped #6211 #6989', function() - meths.set_var('mouse_up', 0) - meths.set_var('mouse_up2', 0) + api.nvim_set_var('mouse_up', 0) + api.nvim_set_var('mouse_up2', 0) command('nnoremap <ScrollWheelUp> <Cmd>let g:mouse_up += 1<CR>') command('nnoremap <2-ScrollWheelUp> <Cmd>let g:mouse_up2 += 1<CR>') feed('<ScrollWheelUp><0,0>') feed('<ScrollWheelUp><0,0>') - meths.input_mouse('wheel', 'up', '', 0, 0, 0) - meths.input_mouse('wheel', 'up', '', 0, 0, 0) - eq(4, meths.get_var('mouse_up')) - eq(0, meths.get_var('mouse_up2')) + api.nvim_input_mouse('wheel', 'up', '', 0, 0, 0) + api.nvim_input_mouse('wheel', 'up', '', 0, 0, 0) + eq(4, api.nvim_get_var('mouse_up')) + eq(0, api.nvim_get_var('mouse_up2')) end) it('<MouseMove> is not translated into multiclicks and can be mapped', function() - meths.set_var('mouse_move', 0) - meths.set_var('mouse_move2', 0) + api.nvim_set_var('mouse_move', 0) + api.nvim_set_var('mouse_move2', 0) command('nnoremap <MouseMove> <Cmd>let g:mouse_move += 1<CR>') command('nnoremap <2-MouseMove> <Cmd>let g:mouse_move2 += 1<CR>') feed('<MouseMove><0,0>') feed('<MouseMove><0,0>') - meths.input_mouse('move', '', '', 0, 0, 0) - meths.input_mouse('move', '', '', 0, 0, 0) - eq(4, meths.get_var('mouse_move')) - eq(0, meths.get_var('mouse_move2')) + api.nvim_input_mouse('move', '', '', 0, 0, 0) + api.nvim_input_mouse('move', '', '', 0, 0, 0) + eq(4, api.nvim_get_var('mouse_move')) + eq(0, api.nvim_get_var('mouse_move2')) end) it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function() @@ -1858,127 +1824,127 @@ describe('ui/mouse/input', function() vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR> ]]) - meths.win_set_cursor(0, {1, 0}) - meths.input_mouse('right', 'press', '', 0, 0, 4) - meths.input_mouse('right', 'release', '', 0, 0, 4) + api.nvim_win_set_cursor(0, { 1, 0 }) + api.nvim_input_mouse('right', 'press', '', 0, 0, 4) + api.nvim_input_mouse('right', 'release', '', 0, 0, 4) feed('<Down><Down><CR>') - eq('bar', meths.get_var('menustr')) - eq({1, 4}, meths.win_get_cursor(0)) + eq('bar', api.nvim_get_var('menustr')) + eq({ 1, 4 }, api.nvim_win_get_cursor(0)) -- Test for right click in visual mode inside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 9}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 11) - meths.input_mouse('right', 'release', '', 0, 0, 11) + api.nvim_input_mouse('right', 'press', '', 0, 0, 11) + api.nvim_input_mouse('right', 'release', '', 0, 0, 11) feed('<Down><CR>') - eq({1, 9}, meths.win_get_cursor(0)) - eq('ran away', funcs.getreg('"')) + eq({ 1, 9 }, api.nvim_win_get_cursor(0)) + eq('ran away', fn.getreg('"')) -- Test for right click in visual mode right before the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 9}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 8) - meths.input_mouse('right', 'release', '', 0, 0, 8) + api.nvim_input_mouse('right', 'press', '', 0, 0, 8) + api.nvim_input_mouse('right', 'release', '', 0, 0, 8) feed('<Down><CR>') - eq({1, 8}, meths.win_get_cursor(0)) - eq('', funcs.getreg('"')) + eq({ 1, 8 }, api.nvim_win_get_cursor(0)) + eq('', fn.getreg('"')) -- Test for right click in visual mode right after the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 9}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 17) - meths.input_mouse('right', 'release', '', 0, 0, 17) + api.nvim_input_mouse('right', 'press', '', 0, 0, 17) + api.nvim_input_mouse('right', 'release', '', 0, 0, 17) feed('<Down><CR>') - eq({1, 17}, meths.win_get_cursor(0)) - eq('', funcs.getreg('"')) + eq({ 1, 17 }, api.nvim_win_get_cursor(0)) + eq('', fn.getreg('"')) -- Test for right click in block-wise visual mode inside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 15}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 15 }) feed('<C-V>j3l') - meths.input_mouse('right', 'press', '', 0, 1, 16) - meths.input_mouse('right', 'release', '', 0, 1, 16) + api.nvim_input_mouse('right', 'press', '', 0, 1, 16) + api.nvim_input_mouse('right', 'release', '', 0, 1, 16) feed('<Down><CR>') - eq({1, 15}, meths.win_get_cursor(0)) - eq('\0224', funcs.getregtype('"')) + eq({ 1, 15 }, api.nvim_win_get_cursor(0)) + eq('\0224', fn.getregtype('"')) -- Test for right click in block-wise visual mode outside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 15}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 15 }) feed('<C-V>j3l') - meths.input_mouse('right', 'press', '', 0, 1, 1) - meths.input_mouse('right', 'release', '', 0, 1, 1) + api.nvim_input_mouse('right', 'press', '', 0, 1, 1) + api.nvim_input_mouse('right', 'release', '', 0, 1, 1) feed('<Down><CR>') - eq({2, 1}, meths.win_get_cursor(0)) - eq('v', funcs.getregtype('"')) - eq('', funcs.getreg('"')) + eq({ 2, 1 }, api.nvim_win_get_cursor(0)) + eq('v', fn.getregtype('"')) + eq('', fn.getreg('"')) -- Test for right click in line-wise visual mode inside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 15}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 15 }) feed('V') - meths.input_mouse('right', 'press', '', 0, 0, 9) - meths.input_mouse('right', 'release', '', 0, 0, 9) + api.nvim_input_mouse('right', 'press', '', 0, 0, 9) + api.nvim_input_mouse('right', 'release', '', 0, 0, 9) feed('<Down><CR>') - eq({1, 0}, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 - eq('V', funcs.getregtype('"')) - eq(1, #funcs.getreg('"', 1, true)) + eq({ 1, 0 }, api.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 + eq('V', fn.getregtype('"')) + eq(1, #fn.getreg('"', 1, true)) -- Test for right click in multi-line line-wise visual mode inside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 15}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 15 }) feed('Vj') - meths.input_mouse('right', 'press', '', 0, 1, 19) - meths.input_mouse('right', 'release', '', 0, 1, 19) + api.nvim_input_mouse('right', 'press', '', 0, 1, 19) + api.nvim_input_mouse('right', 'release', '', 0, 1, 19) feed('<Down><CR>') - eq({1, 0}, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 - eq('V', funcs.getregtype('"')) - eq(2, #funcs.getreg('"', 1, true)) + eq({ 1, 0 }, api.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1 + eq('V', fn.getregtype('"')) + eq(2, #fn.getreg('"', 1, true)) -- Test for right click in line-wise visual mode outside the selection - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 15}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 15 }) feed('V') - meths.input_mouse('right', 'press', '', 0, 1, 9) - meths.input_mouse('right', 'release', '', 0, 1, 9) + api.nvim_input_mouse('right', 'press', '', 0, 1, 9) + api.nvim_input_mouse('right', 'release', '', 0, 1, 9) feed('<Down><CR>') - eq({2, 9}, meths.win_get_cursor(0)) - eq('', funcs.getreg('"')) + eq({ 2, 9 }, api.nvim_win_get_cursor(0)) + eq('', fn.getreg('"')) -- Try clicking outside the window - funcs.setreg('"', '') - meths.win_set_cursor(0, {2, 1}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 2, 1 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 6, 1) - meths.input_mouse('right', 'release', '', 0, 6, 1) + api.nvim_input_mouse('right', 'press', '', 0, 6, 1) + api.nvim_input_mouse('right', 'release', '', 0, 6, 1) feed('<Down><CR>') - eq(2, funcs.winnr()) - eq('', funcs.getreg('"')) + eq(2, fn.winnr()) + eq('', fn.getreg('"')) -- Test for right click in visual mode inside the selection with vertical splits command('wincmd t') command('rightbelow vsplit') - funcs.setreg('"', '') - meths.win_set_cursor(0, {1, 9}) + fn.setreg('"', '') + api.nvim_win_set_cursor(0, { 1, 9 }) feed('vee') - meths.input_mouse('right', 'press', '', 0, 0, 52) - meths.input_mouse('right', 'release', '', 0, 0, 52) + api.nvim_input_mouse('right', 'press', '', 0, 0, 52) + api.nvim_input_mouse('right', 'release', '', 0, 0, 52) feed('<Down><CR>') - eq({1, 9}, meths.win_get_cursor(0)) - eq('ran away', funcs.getreg('"')) + eq({ 1, 9 }, api.nvim_win_get_cursor(0)) + eq('ran away', fn.getreg('"')) -- Test for right click inside visual selection at bottom of window with winbar command('setlocal winbar=WINBAR') feed('2yyP') - funcs.setreg('"', '') + fn.setreg('"', '') feed('G$vbb') - meths.input_mouse('right', 'press', '', 0, 4, 61) - meths.input_mouse('right', 'release', '', 0, 4, 61) + api.nvim_input_mouse('right', 'press', '', 0, 4, 61) + api.nvim_input_mouse('right', 'release', '', 0, 4, 61) feed('<Down><CR>') - eq({4, 20}, meths.win_get_cursor(0)) - eq('the moon', funcs.getreg('"')) + eq({ 4, 20 }, api.nvim_win_get_cursor(0)) + eq('the moon', fn.getreg('"')) end) end) diff --git a/test/functional/ui/multibyte_spec.lua b/test/functional/ui/multibyte_spec.lua index d72bf27d6b..c2fc763401 100644 --- a/test/functional/ui/multibyte_spec.lua +++ b/test/functional/ui/multibyte_spec.lua @@ -5,51 +5,49 @@ local command = helpers.command local feed = helpers.feed local feed_command = helpers.feed_command local insert = helpers.insert -local funcs = helpers.funcs -local meths = helpers.meths -local split = helpers.split +local fn = helpers.fn +local api = helpers.api +local split = vim.split local dedent = helpers.dedent -describe("multibyte rendering", function() +describe('multibyte rendering', function() local screen before_each(function() clear() screen = Screen.new(60, 6) - screen:attach({rgb=true}) + screen:attach({ rgb = true }) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}, - [2] = {background = Screen.colors.WebGray}, - [3] = {background = Screen.colors.LightMagenta}, - [4] = {bold = true}, - [5] = {foreground = Screen.colors.Blue}, + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { background = Screen.colors.WebGray }, + [3] = { background = Screen.colors.LightMagenta }, + [4] = { bold = true }, + [5] = { foreground = Screen.colors.Blue }, + [6] = { reverse = true, bold = true }, + [7] = { reverse = true }, }) end) - it("works with composed char at start of line", function() + it('works with composed char at start of line', function() insert([[ ̊ x]]) - feed("gg") - -- verify the modifier in fact is alone - feed_command("ascii") + feed('gg') + -- verify the modifier in fact is alone + feed_command('ascii') screen:expect([[ ^ ̊ | x | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 < ̊> 778, Hex 030a, Octal 1412 | ]]) -- a char inserted before will spontaneously merge with it - feed("ia<esc>") - feed_command("ascii") + feed('ia<esc>') + feed_command('ascii') screen:expect([[ ^å | x | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 <a> 97, Hex 61, Octal 141 < ̊> 778, Hex 030a, Octal 1412 | ]]) end) @@ -58,10 +56,7 @@ describe("multibyte rendering", function() feed('58a <esc>a馬<esc>') screen:expect([[ ^馬| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | ]]) @@ -69,9 +64,7 @@ describe("multibyte rendering", function() screen:expect([[ ^ {1:>}| 馬 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) @@ -79,9 +72,7 @@ describe("multibyte rendering", function() screen:expect([[ {1:>}| ^馬 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) @@ -91,20 +82,17 @@ describe("multibyte rendering", function() screen:expect([[ ab ^ | -馬 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4:-- INSERT --} | ]]) - -- check double-with char is temporarily hidden when overlapped - funcs.complete(4, {'xx', 'yy'}) + -- check double-width char is temporarily hidden when overlapped + fn.complete(4, { 'xx', 'yy' }) screen:expect([[ ab xx^ | - {2: xx } | {1:~ }{3: yy }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {4:-- INSERT --} | ]]) @@ -113,29 +101,60 @@ describe("multibyte rendering", function() screen:expect([[ ab xxz^ | -馬 | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4:-- INSERT --} | ]]) end) + it('no stray chars when splitting left of window with double-width chars', function() + api.nvim_buf_set_lines(0, 0, -1, true, { + ('口'):rep(16), + 'a' .. ('口'):rep(16), + 'aa' .. ('口'):rep(16), + 'aaa' .. ('口'):rep(16), + 'aaaa' .. ('口'):rep(16), + }) + screen:expect([[ + ^口口口口口口口口口口口口口口口口 | + a口口口口口口口口口口口口口口口口 | + aa口口口口口口口口口口口口口口口口 | + aaa口口口口口口口口口口口口口口口口 | + aaaa口口口口口口口口口口口口口口口口 | + | + ]]) + + command('20vnew') + screen:expect([[ + ^ │口口口口口口口口口口口口口口口口 | + {1:~ }│a口口口口口口口口口口口口口口口口 | + {1:~ }│aa口口口口口口口口口口口口口口口口 | + {1:~ }│aaa口口口口口口口口口口口口口口口口 | + {6:[No Name] }{7:[No Name] [+] }| + | + ]]) + end) + it('0xffff is shown as 4 hex digits', function() command([[call setline(1, "\uFFFF!!!")]]) feed('$') - screen:expect{grid=[[ + screen:expect { + grid = [[ {5:<ffff>}!!^! | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } end) it('works with a lot of unicode (zalgo) text', function() screen:try_resize(65, 10) - meths.buf_set_lines(0,0,-1,true, split(dedent [[ + api.nvim_buf_set_lines( + 0, + 0, + -1, + true, + split( + dedent [[ L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ @@ -144,11 +163,14 @@ describe("multibyte rendering", function() ē̟̊̇̕̚s̖̘̘̒̄̑s̛̘̀̊̆̇e̛̝̘̒̏̚ ̉̅̑̂̐̎c̛̟̙̎̋̓i̜̇̒̏̆̆l̟̄́̆̊̌l̍̊̋̃̆̌ủ̗̙̒̔̚m̛̘̘̖̅̍ ̖̙̈̎̂̕d̞̟̏̋̈̔ơ̟̝̌̃̄l̗̙̝̂̉̒õ̒̃̄̄̚ŕ̗̏̏̊̍ê̞̝̞̋̈ ̜̔̒̎̃̚e̞̟̞̒̃̄ư̖̏̄̑̃ ̛̗̜̄̓̎f̛̖̞̅̓̃ü̞̏̆̋̕g̜̝̞̑̑̆i̛̘̐̐̅̚à̜̖̌̆̎t̙̙̎̉̂̍ ̋̔̈̎̎̉n̞̓́̔̊̕ư̘̅̋̔̚l̗̍̒̄̀̚l̞̗̘̙̓̍â̘̔̒̎̚ ̖̓̋̉̃̆p̛̛̘̋̌̀ä̙̔́̒̕r̟̟̖̋̐̋ì̗̙̎̓̓ȃ̔̋̑̚̕t̄́̎̓̂̋ư̏̈̂̑̃r̖̓̋̊̚̚.̒̆̑̆̊̎ ̘̜̍̐̂̚E̞̅̐̇́̂x̄́̈̌̉̕ć̘̃̉̃̕è̘̂̑̏̑p̝̘̑̂̌̆t̔̐̅̍̌̂ȇ̞̈̐̚̕ű̝̞̜́̚ŕ̗̝̉̆́ š̟́̔̏̀ȉ̝̟̝̏̅n̑̆̇̒̆̚t̝̒́̅̋̏ ̗̑̌̋̇̚ơ̙̗̟̆̅c̙̞̙̎̊̎c̘̟̍̔̊̊a̛̒̓̉́̐e̜̘̙̒̅̇ć̝̝̂̇̕ả̓̍̎̂̚t̗̗̗̟̒̃ ̘̒̓̐̇́c̟̞̉̐̓̄ȕ̙̗̅́̏p̛̍̋̈́̅i̖̓̒̍̈̄d̞̃̈̌̆̐a̛̗̝̎̋̉t̞̙̀̊̆̇a̛̙̒̆̉̚t̜̟̘̉̓̚ ̝̘̗̐̇̕n̛̘̑̏̂́ō̑̋̉̏́ň̞̊̆̄̃ ̙̙̙̜̄̏p̒̆̋̋̓̏r̖̖̅̉́̚ơ̜̆̑̈̚i̟̒̀̃̂̌d̛̏̃̍̋̚ë̖̞̙̗̓n̛̘̓̒̅̎t̟̗̙̊̆̚,̘̙̔̊̚̕ ̟̗̘̜̑̔s̜̝̍̀̓̌û̞̙̅̇́n̘̗̝̒̃̎t̗̅̀̅̊̈ ̗̖̅̅̀̄i̛̖̍̅̋̂n̙̝̓̓̎̚ ̞̋̅̋̃̚c̗̒̀̆̌̎ū̞̂̑̌̓ĺ̛̐̍̑́p̝̆̌̎̈̚a̖̙̒̅̈̌ ̝̝̜̂̈̀q̝̖̔̍̒̚ư̔̐̂̎̊ǐ̛̟̖̘̕ o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚]], - '\n')) + '\n' + ) + ) -- tests that we can handle overflow of the buffer -- for redraw events (4096 bytes) gracefully - screen:expect{grid=[[ + screen:expect { + grid = [[ ^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ | ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ | U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ | @@ -159,12 +181,14 @@ describe("multibyte rendering", function() o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚ | {1:~ }| | - ]]} + ]], + } -- nvim will reset the zalgo text^W^W glyph cache if it gets too full. -- this should be exceedingly rare, but fake it to make sure it works - meths._invalidate_glyph_cache() - screen:expect{grid=[[ + api.nvim__invalidate_glyph_cache() + screen:expect { + grid = [[ ^L̓̉̑̒̌̚ơ̗̌̒̄̀ŕ̈̈̎̐̕è̇̅̄̄̐m̖̟̟̅̄̚ ̛̓̑̆̇̍i̗̟̞̜̅̐p̗̞̜̉̆̕s̟̜̘̍̑̏ū̟̞̎̃̉ḿ̘̙́́̐ ̖̍̌̇̉̚d̞̄̃̒̉̎ò́̌̌̂̐l̞̀̄̆̌̚ȯ̖̞̋̀̐r̓̇̌̃̃̚ ̗̘̀̏̍́s̜̀̎̎̑̕i̟̗̐̄̄̚t̝̎̆̓̐̒ ̘̇̔̓̊̚ȃ̛̟̗̏̅m̜̟̙̞̈̓é̘̞̟̔̆t̝̂̂̈̑̔,̜̜̖̅̄̍ ̛̗̊̓̆̚c̟̍̆̍̈̔ȯ̖̖̝̑̀n̜̟̎̊̃̚s̟̏̇̎̒̚e̙̐̈̓̌̚c̙̍̈̏̅̕ť̇̄̇̆̓e̛̓̌̈̓̈t̟̍̀̉̆̅u̝̞̎̂̄̚r̘̀̅̈̅̐ ̝̞̓́̇̉ã̏̀̆̅̕d̛̆̐̉̆̋ȉ̞̟̍̃̚p̛̜̊̍̂̓ȋ̏̅̃̋̚ṥ̛̏̃̕č̛̞̝̀̂í̗̘̌́̎n̔̎́̒̂̕ǧ̗̜̋̇̂ ̛̜̔̄̎̃ê̛̔̆̇̕l̘̝̏̐̊̏ĩ̛̍̏̏̄t̟̐́̀̐̎,̙̘̍̆̉̐ ̋̂̏̄̌̅s̙̓̌̈́̇e̛̗̋̒̎̏d̜̗̊̍̊̚ | ď̘̋̌̌̕ǒ̝̗̔̇̕ ̙̍́̄̄̉è̛̛̞̌̌i̜̖̐̈̆̚ȕ̇̈̓̃̓ŝ̛̞̙̉̋m̜̐̂̄̋̂ȯ̈̎̎̅̕d̜̙̓̔̋̑ ̞̗̄̂̂̚t̝̊́̃́̄e̛̘̜̞̓̑m̊̅̏̉̌̕p̛̈̂̇̀̐ỏ̙̘̈̉̔r̘̞̋̍̃̚ ̝̄̀̇̅̇ỉ̛̖̍̓̈n̛̛̝̎̕̕c̛̛̊̅́̐ĭ̗̓̀̍̐d̞̜̋̐̅̚i̟̙̇̄̊̄d̞̊̂̀̇̚ủ̝̉̑̃̕n̜̏̇̄̐̋ť̗̜̞̋̉ ̝̒̓̌̓̚ȕ̖̙̀̚̕t̖̘̎̉̂̌ ̛̝̄̍̌̂l̛̟̝̃̑̋á̛̝̝̔̅b̝̙̜̗̅̒ơ̖̌̒̄̆r̒̇̓̎̈̄e̛̛̖̅̏̇ ̖̗̜̝̃́e̛̛̘̅̔̌ẗ̛̙̗̐̕ ̖̟̇̋̌̈d̞̙̀̉̑̕ŏ̝̂́̐̑l̞̟̗̓̓̀ơ̘̎̃̄̂r̗̗̖̔̆̍ẻ̖̝̞̋̅ ̜̌̇̍̈̊m̈̉̇̄̒̀a̜̞̘̔̅̆g̗̖̈̃̈̉n̙̖̄̈̉̄â̛̝̜̄̃ ̛́̎̕̕̚ā̊́́̆̌l̟̙̞̃̒́i̖̇̎̃̀̋q̟̇̒̆́̊ủ́̌̇̑̚ã̛̘̉̐̚.̛́̏̐̍̊ | U̝̙̎̈̐̆t̜̍̌̀̔̏ ̞̉̍̇̈̃e̟̟̊̄̕̕n̝̜̒̓̆̕i̖̒̌̅̇̚m̞̊̃̔̊̂ ̛̜̊̎̄̂a̘̜̋̒̚̚d̟̊̎̇̂̍ ̜̖̏̑̉̕m̜̒̎̅̄̚i̝̖̓̂̍̕n̙̉̒̑̀̔ỉ̖̝̌̒́m̛̖̘̅̆̎ ̖̉̎̒̌̕v̖̞̀̔́̎e̖̙̗̒̎̉n̛̗̝̎̀̂ȉ̞̗̒̕̚ȧ̟̜̝̅̚m̆̉̐̐̇̈,̏̐̎́̍́ ̜̞̙̘̏̆q̙̖̙̅̓̂ủ̇́̀̔̚í̙̟̟̏̐s̖̝̍̏̂̇ ̛̘̋̈̕̕ń̛̞̜̜̎o̗̜̔̔̈̆s̞̘̘̄̒̋t̛̅̋́̔̈ȓ̓̒́̇̅ủ̜̄̃̒̍d̙̝̘̊̏̚ ̛̟̞̄́̔e̛̗̝̍̃̀x̞̖̃̄̂̅e̖̅̇̐̔̃r̗̞̖̔̎̚c̘̜̖̆̊̏ï̙̝̙̂̕t̖̏́̓̋̂ă̖̄̆̑̒t̜̟̍̉̑̏i̛̞̞̘̒̑ǒ̜̆̅̃̉ṅ̖̜̒̎̚ | @@ -175,7 +199,9 @@ describe("multibyte rendering", function() o̖̜̔̋̅̚f̛̊̀̉́̕f̏̉̀̔̃̃i̘̍̎̐̔̎c̙̅̑̂̐̅ȋ̛̜̀̒̚a̋̍̇̏̀̋ ̖̘̒̅̃̒d̗̘̓̈̇̋é̝́̎̒̄š̙̒̊̉̋e̖̓̐̀̍̕r̗̞̂̅̇̄ù̘̇̐̉̀n̐̑̀̄̍̐t̟̀̂̊̄̚ ̟̝̂̍̏́m̜̗̈̂̏̚ő̞̊̑̇̒l̘̑̏́̔̄l̛̛̇̃̋̊i̓̋̒̃̉̌t̛̗̜̏̀̋ ̙̟̒̂̌̐a̙̝̔̆̏̅n̝̙̙̗̆̅i̍̔́̊̃̕m̖̝̟̒̍̚ ̛̃̃̑̌́ǐ̘̉̔̅̚d̝̗̀̌̏̒ ̖̝̓̑̊̚ȇ̞̟̖̌̕š̙̙̈̔̀t̂̉̒̍̄̄ ̝̗̊̋̌̄l̛̞̜̙̘̔å̝̍̂̍̅b̜̆̇̈̉̌ǒ̜̙̎̃̆r̝̀̄̍́̕ư̋̊́̊̕m̜̗̒̐̕̚.̟̘̀̒̌̚ | {1:~ }| | - ]], reset=true} + ]], + reset = true, + } end) it('works with arabic input and arabicshape', function() @@ -183,24 +209,22 @@ describe("multibyte rendering", function() command('set noarabicshape') feed('isghl!<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^!مالس| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*4 | - ]]} + ]], + } command('set arabicshape') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^!ﻡﻼﺳ| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*4 | - ]]} + ]], + } end) it('works with arabic input and arabicshape and norightleft', function() @@ -208,25 +232,22 @@ describe("multibyte rendering", function() command('set noarabicshape') feed('isghl!<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ سلام^! | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } command('set arabicshape') - screen:expect{grid=[[ + screen:expect { + grid = [[ ﺱﻼﻣ^! | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} - + ]], + } end) it('works with arabicshape and multiple composing chars', function() @@ -236,27 +257,25 @@ describe("multibyte rendering", function() -- If we would increase the schar_t size, say from 32 to 64 bytes, we need to extend the -- test text with even more zalgo energy to still touch this edge case. - meths.buf_set_lines(0,0,-1,true, {"سلام့̀́̂̃̄̅̆̇̈̉̊̋̌"}) + api.nvim_buf_set_lines(0, 0, -1, true, { 'سلام့̀́̂̃̄̅̆̇̈̉̊̋̌' }) command('set noarabicshape') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^سلام့̀́̂̃̄̅̆̇̈̉̊̋̌ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } command('set arabicshape') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ﺱﻼﻣ̀́̂̃̄̅̆̇̈̉̊̋̌ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 | - ]]} + ]], + } end) end) @@ -267,9 +286,9 @@ describe('multibyte rendering: statusline', function() clear() screen = Screen.new(40, 4) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {bold = true, reverse = true}, - [3] = {background = Screen.colors.Red, foreground = Screen.colors.Gray100}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { bold = true, reverse = true }, + [3] = { background = Screen.colors.Red, foreground = Screen.colors.Gray100 }, }) screen:attach() command('set laststatus=2') @@ -325,34 +344,40 @@ describe('multibyte rendering: statusline', function() it('hidden group %( %) does not cause invalid unicode', function() command("let &statusline = '%#StatColorHi2#%(✓%#StatColorHi2#%) Q≡'") - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }| {2: Q≡ }| | - ]]} + ]], + } end) it('unprintable chars in filename with default stl', function() - command("file 🧑💻") + command('file 🧑💻') -- TODO: this is wrong but avoids a crash - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }| {2:🧑�💻 }| | - ]]} + ]], + } end) it('unprintable chars in filename with custom stl', function() command('set statusline=xx%#ErrorMsg#%f%##yy') - command("file 🧑💻") + command('file 🧑💻') -- TODO: this is also wrong but also avoids a crash - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | {1:~ }| {2:xx}{3:🧑<200d>💻}{2:yy }| | - ]]} + ]], + } end) end) diff --git a/test/functional/ui/multigrid_spec.lua b/test/functional/ui/multigrid_spec.lua index 5b982df2b5..c1d3af085f 100644 --- a/test/functional/ui/multigrid_spec.lua +++ b/test/functional/ui/multigrid_spec.lua @@ -3,9 +3,9 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local feed, command, insert = helpers.feed, helpers.command, helpers.insert local eq = helpers.eq -local funcs = helpers.funcs -local meths = helpers.meths -local curwin = helpers.curwin +local fn = helpers.fn +local api = helpers.api +local curwin = helpers.api.nvim_get_current_win local poke_eventloop = helpers.poke_eventloop @@ -36,7 +36,7 @@ describe('ext_multigrid', function() [17] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, [18] = {bold = true, foreground = Screen.colors.Magenta}, [19] = {foreground = Screen.colors.Brown}, - [20] = {background = Screen.colors.LightGrey}, + [20] = {background = Screen.colors.LightGrey, foreground = Screen.colors.Black}, [21] = {background = Screen.colors.LightMagenta}, [22] = {background = Screen.colors.LightMagenta, bold = true, foreground = Screen.colors.Blue}, [23] = {background = Screen.colors.Grey90}, @@ -47,33 +47,12 @@ describe('ext_multigrid', function() it('default initial screen', function() screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ]]} @@ -83,144 +62,71 @@ describe('ext_multigrid', function() command('vsplit') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*12 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]], condition=function() eq({ - [2] = { win = {id=1000}, startrow = 0, startcol = 27, width = 26, height = 12 }, - [4] = { win = {id=1001}, startrow = 0, startcol = 0, width = 26, height = 12 } + [2] = { win = 1000, startrow = 0, startcol = 27, width = 26, height = 12 }, + [4] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 } }, screen.win_position) end} command('wincmd l') command('split') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| + [4:--------------------------]│[5:--------------------------]|*6 [4:--------------------------]│{11:[No Name] }| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*5 {12:[No Name] [No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]], condition=function() eq({ - [2] = { win = {id=1000}, startrow = 7, startcol = 27, width = 26, height = 5 }, - [4] = { win = {id=1001}, startrow = 0, startcol = 0, width = 26, height = 12 }, - [5] = { win = {id=1002}, startrow = 0, startcol = 27, width = 26, height = 6 } + [2] = { win = 1000, startrow = 7, startcol = 27, width = 26, height = 5 }, + [4] = { win = 1001, startrow = 0, startcol = 0, width = 26, height = 12 }, + [5] = { win = 1002, startrow = 0, startcol = 27, width = 26, height = 6 } }, screen.win_position) end} command('wincmd h') command('q') screen:expect{grid=[[ ## grid 1 - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| + [5:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]], condition=function() eq({ - [2] = { win = {id=1000}, startrow = 7, startcol = 0, width = 53, height = 5 }, - [5] = { win = {id=1002}, startrow = 0, startcol = 0, width = 53, height = 6 } + [2] = { win = 1000, startrow = 7, startcol = 0, width = 53, height = 5 }, + [5] = { win = 1002, startrow = 0, startcol = 0, width = 53, height = 6 } }, screen.win_position) end} end) @@ -231,35 +137,19 @@ describe('ext_multigrid', function() command('sp') screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]) end) @@ -268,35 +158,19 @@ describe('ext_multigrid', function() command('resize 8') screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*8 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*3 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 ]]) end) @@ -306,162 +180,77 @@ describe('ext_multigrid', function() command('vsp') screen:expect{grid=[[ ## grid 1 - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| + [6:--------------------]│[5:----------------]│[4:---------------]|*6 {11:[No Name] }{12:[No Name] [No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 6 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} insert('hello') screen:expect{grid=[[ ## grid 1 - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| - [6:--------------------]│[5:----------------]│[4:---------------]| + [6:--------------------]│[5:----------------]│[4:---------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] [No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 6 hell^o | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} end) it('closes splits', function () command('sp') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} command('q') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ]]} @@ -473,48 +262,17 @@ describe('ext_multigrid', function() command('vsp') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*12 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]]} end) it('resizes grids', function () @@ -522,48 +280,17 @@ describe('ext_multigrid', function() command('vertical resize 10') screen:expect{grid=[[ ## grid 1 - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| - [4:----------]│[2:------------------------------------------]| + [4:----------]│[2:------------------------------------------]|*12 {11:<No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]]} end) it('splits horizontally', function () @@ -571,173 +298,69 @@ describe('ext_multigrid', function() command('sp') screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| + [5:--------------------------]│[2:--------------------------]|*6 {11:[No Name] }│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*5 {12:[No Name] [No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} insert('hello') screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| + [5:--------------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*5 {12:[No Name] [+] [No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 hello | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 5 hell^o | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} end) it('closes splits', function () command('vsp') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*12 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]]} command('q') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ]]} @@ -750,17 +373,12 @@ describe('ext_multigrid', function() screen:try_resize(25, 6) screen:expect{grid=[[ ## grid 1 - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| - [2:-------------------------]| + [2:-------------------------]|*4 {11:[No Name] }| [3:-------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ]]} @@ -799,26 +417,12 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ]]} @@ -831,41 +435,12 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*19 ## grid 3 | ]]} @@ -879,52 +454,30 @@ describe('ext_multigrid', function() end) it('winwidth() winheight() getwininfo() return inner width and height #19743', function() - eq(60, funcs.winwidth(0)) - eq(20, funcs.winheight(0)) - local win_info = funcs.getwininfo(curwin().id)[1] + eq(60, fn.winwidth(0)) + eq(20, fn.winheight(0)) + local win_info = fn.getwininfo(curwin())[1] eq(60, win_info.width) eq(20, win_info.height) end) + it("'scroll' option works properly", function() + eq(10, api.nvim_get_option_value('scroll', { win = 0 })) + api.nvim_set_option_value('scroll', 15, { win = 0 }) + eq(15, api.nvim_get_option_value('scroll', { win = 0 })) + end) + it('gets written till grid width', function() insert(('a'):rep(60).."\n") screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*18 ## grid 3 | ]]} @@ -936,82 +489,24 @@ describe('ext_multigrid', function() feed('0') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 ^aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa哦| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*19 ## grid 3 | ]]} feed('g$') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^哦| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*19 ## grid 3 | ]]} @@ -1021,41 +516,14 @@ describe('ext_multigrid', function() insert(('b'):rep(160).."\n") screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| - bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb| + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb|*2 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*16 ## grid 3 | ]]} @@ -1063,18 +531,7 @@ describe('ext_multigrid', function() command('setlocal cursorline cursorlineopt=screenline') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 @@ -1082,22 +539,7 @@ describe('ext_multigrid', function() {23:^bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}| bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*16 ## grid 3 | ]]} @@ -1108,41 +550,12 @@ describe('ext_multigrid', function() ' long message"') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*19 ## grid 3 this is a very very very...ry very very long message | ]]} @@ -1153,41 +566,13 @@ describe('ext_multigrid', function() feed('kzfgg') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 {13:^+-- 2 lines: this is a fold································}| this is outside fold | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*18 ## grid 3 | ]]} @@ -1197,46 +582,18 @@ describe('ext_multigrid', function() insert(('c'):rep(1111)) screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|*18 cccccccccccccccccccccccccccccc^c | {1:~ }| ## grid 3 | ]]} - local float_buf = meths.create_buf(false, false) - meths.open_win(float_buf, false, { + local float_buf = api.nvim_create_buf(false, false) + api.nvim_open_win(float_buf, false, { relative = 'win', win = curwin(), bufpos = {0, 1018}, @@ -1246,51 +603,20 @@ describe('ext_multigrid', function() }) screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| - cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc| + cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc|*18 cccccccccccccccccccccccccccccc^c | {1:~ }| ## grid 3 | ## grid 4 {21: }| - {22:~ }| - {22:~ }| - {22:~ }| - {22:~ }| + {22:~ }|*4 ]], float_pos={ - [4] = {{id = 1001}, "SE", 2, 16, 58, true, 50}; + [4] = {1001, "SE", 2, 16, 58, true, 50}; }} end) @@ -1299,48 +625,20 @@ describe('ext_multigrid', function() feed('A<C-X><C-N>') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - | - | - | - | - | - | - | - | - | - | - | - | - | - | + |*14 foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | ## grid 4 {24: foo}| {21: bar}| ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 15, 55, false, 100}; + [4] = {-1, "NW", 2, 15, 55, false, 100}; }} feed('<C-E><Esc>') @@ -1348,48 +646,21 @@ describe('ext_multigrid', function() feed('o<C-X><C-N>') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - | - | - | - | - | - | - | - | - | - | - | - | - | - | + |*14 rab oof rab oof rab oof rab oof rab oof rab oof rab oof| ^ oof| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*4 ## grid 3 {7:-- Keyword Local completion (^N^P) }{15:match 1 of 2} | ## grid 4 {24: oof}| {21: rab}| ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 16, 45, false, 100}; + [4] = {-1, "NW", 2, 16, 45, false, 100}; }} feed('<C-E><Esc>') @@ -1397,48 +668,21 @@ describe('ext_multigrid', function() feed(':sign un<Tab>') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 - | - | - | - | - | - | - | - | - | - | - | - | - | - | + |*14 rab oof rab oof rab oof rab oof rab oof rab oof rab oof| | - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*4 ## grid 3 :sign undefine^ | ## grid 4 {24: undefine }| {21: unplace }| ]], float_pos={ - [4] = {{id = -1}, "SW", 1, 13, 5, false, 250}; + [4] = {-1, "SW", 1, 13, 5, false, 250}; }} end) end) @@ -1448,67 +692,34 @@ describe('ext_multigrid', function() command('vsp') screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| + [5:--------------------------]│[4:--------------------------]|*6 {11:[No Name] }{12:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} feed(":echoerr 'very' | echoerr 'much' | echoerr 'fail'<cr>") screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| + [5:--------------------------]│[4:--------------------------]|*6 {11:[No Name] }{12:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*3 + [3:-----------------------------------------------------]|*4 ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 {14:very} | {14:much} | @@ -1516,59 +727,31 @@ describe('ext_multigrid', function() {15:Press ENTER or type command to continue}^ | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} feed('<cr>') screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| + [5:--------------------------]│[4:--------------------------]|*6 {11:[No Name] }{12:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} command([[ @@ -1580,26 +763,10 @@ describe('ext_multigrid', function() feed(":call ErrMsg()<cr>") screen:expect{grid=[[ ## grid 1 - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| + [3:-----------------------------------------------------]|*14 ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 {14:Error detected while processing function ErrMsg:} | {19:line 2:} | @@ -1617,59 +784,31 @@ describe('ext_multigrid', function() {15:Press ENTER or type command to continue}^ | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} feed("<c-c>") screen:expect{grid=[[ ## grid 1 - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| - [5:--------------------------]│[4:--------------------------]| + [5:--------------------------]│[4:--------------------------]|*6 {11:[No Name] }{12:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} end) @@ -1677,48 +816,17 @@ describe('ext_multigrid', function() command('vsp') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*12 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]]} @@ -1727,232 +835,93 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 {16: }{17:2}{16: [No Name] }{7: [No Name] }{12: }{16:X}| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| + [5:-----------------------------------------------------]|*11 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 5 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ]]} command('sp') screen:expect{grid=[[ ## grid 1 {16: }{17:2}{16: [No Name] }{7: }{18:2}{7: [No Name] }{12: }{16:X}| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| + [6:-----------------------------------------------------]|*5 {11:[No Name] }| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| + [5:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 6 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} command('tabnext') screen:expect{grid=[[ ## grid 1 {7: }{18:2}{7: [No Name] }{16: }{17:2}{16: [No Name] }{12: }{16:X}| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*11 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 5 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 6 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} command('tabnext') screen:expect{grid=[[ ## grid 1 {16: }{17:2}{16: [No Name] }{7: }{18:2}{7: [No Name] }{12: }{16:X}| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| - [6:-----------------------------------------------------]| + [6:-----------------------------------------------------]|*5 {11:[No Name] }| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| - [5:-----------------------------------------------------]| + [5:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 3 | ## grid 4 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 5 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 6 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} command('tabnext') @@ -1960,117 +929,43 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 {16: }{17:2}{16: [No Name] }{17:2}{16: [No Name] }{7: [No Name] }{12: }{16:X}| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| - [7:-----------------------------------------------------]| + [7:-----------------------------------------------------]|*11 {11:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 3 | ## grid 4 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 5 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 6 (hidden) | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 7 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ]]} command('tabclose') command('tabclose') screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*12 {11:[No Name] }{12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ]]} end) @@ -2078,67 +973,27 @@ describe('ext_multigrid', function() insert('some text\nto be clicked') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicke^d | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 3 | ]]} - meths.input_mouse('left', 'press', '', 2, 0, 5) + api.nvim_input_mouse('left', 'press', '', 2, 0, 5) screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some ^text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 ## grid 3 | ]]} @@ -2148,128 +1003,75 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 Lorem ipsum dolor sit amet, consectetur adipiscing el| it, sed do eiusm^o | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} - meths.input_mouse('left', 'press', '', 2, 1, 6) + api.nvim_input_mouse('left', 'press', '', 2, 1, 6) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {12:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be ^clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 Lorem ipsum dolor sit amet, consectetur adipiscing el| it, sed do eiusmo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} - meths.input_mouse('left', 'press', '', 4, 1, 4) + api.nvim_input_mouse('left', 'press', '', 4, 1, 4) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 Lorem ipsum dolor sit amet, consectetur adipiscing el| it, ^sed do eiusmo | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} screen:try_resize_grid(4, 80, 2) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -2277,29 +1079,18 @@ describe('ext_multigrid', function() {1:~ }| ]]} - meths.input_mouse('left', 'press', '', 4, 0, 64) + api.nvim_input_mouse('left', 'press', '', 4, 0, 64) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -2308,36 +1099,23 @@ describe('ext_multigrid', function() ]]} -- XXX: mouse_check_grid() doesn't work properly when clicking on grid 1 - meths.input_mouse('left', 'press', '', 1, 6, 20) + api.nvim_input_mouse('left', 'press', '', 1, 6, 20) -- TODO(bfredl): "batching" input_mouse is formally not supported yet. -- Normally it should work fine in async context when nvim is not blocked, -- but add a poke_eventloop be sure. poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 4, 20) + api.nvim_input_mouse('left', 'drag', '', 1, 4, 20) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] [+] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*7 {12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -2348,28 +1126,15 @@ describe('ext_multigrid', function() feed('<c-w><c-w><c-w>v') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {12:[No Name] [+] }| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| - [5:--------------------------]│[2:--------------------------]| + [5:--------------------------]│[2:--------------------------]|*7 {11:[No Name] [+] }{12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -2378,40 +1143,23 @@ describe('ext_multigrid', function() ## grid 5 some text | to be ^clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} - meths.input_mouse('left', 'press', '', 1, 8, 26) + api.nvim_input_mouse('left', 'press', '', 1, 8, 26) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 30) + api.nvim_input_mouse('left', 'drag', '', 1, 6, 30) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {12:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {11:[No Name] [+] }{12:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -2420,41 +1168,24 @@ describe('ext_multigrid', function() ## grid 5 some text | to be ^clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} command('aunmenu PopUp | vmenu PopUp.Copy y') - funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 2, 1, 6) + fn.setreg('"', '') + api.nvim_input_mouse('left', 'press', '2', 2, 1, 6) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {12:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] }{11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be {20:clicke}^d | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2463,38 +1194,21 @@ describe('ext_multigrid', function() ## grid 5 some text | to be {20:clicked} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} - meths.input_mouse('right', 'press', '', 2, 1, 6) - meths.input_mouse('right', 'release', '', 2, 1, 6) + api.nvim_input_mouse('right', 'press', '', 2, 1, 6) + api.nvim_input_mouse('right', 'release', '', 2, 1, 6) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {12:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] }{11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be {20:clicke}^d | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2503,41 +1217,24 @@ describe('ext_multigrid', function() ## grid 5 some text | to be {20:clicked} | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 6 {21: Copy }| ]], float_pos={ - [6] = {{id = -1}, "NW", 2, 2, 5, false, 250}; + [6] = {-1, "NW", 2, 2, 5, false, 250}; }} feed('<Down><CR>') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {12:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] }{11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be ^clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -2546,40 +1243,23 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} - eq('clicked', funcs.getreg('"')) + eq('clicked', fn.getreg('"')) - funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 0, 64) + fn.setreg('"', '') + api.nvim_input_mouse('left', 'press', '2', 4, 0, 64) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] [No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2588,38 +1268,21 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} - meths.input_mouse('right', 'press', '', 4, 0, 64) - meths.input_mouse('right', 'release', '', 4, 0, 64) + api.nvim_input_mouse('right', 'press', '', 4, 0, 64) + api.nvim_input_mouse('right', 'release', '', 4, 0, 64) screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] [No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2628,41 +1291,24 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 6 {21: Copy }| ]], float_pos={ - [6] = {{id = -1}, "NW", 4, 1, 63, false, 250}; + [6] = {-1, "NW", 4, 1, 63, false, 250}; }} feed('<Down><CR>') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] [+] }| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*7 {12:[No Name] [+] [No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 @@ -2671,38 +1317,23 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]} - eq('eiusmo', funcs.getreg('"')) + eq('eiusmo', fn.getreg('"')) command('wincmd J') screen:try_resize_grid(4, 7, 10) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -2719,35 +1350,22 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 9, 1) + fn.setreg('"', '') + api.nvim_input_mouse('left', 'press', '2', 4, 9, 1) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2764,34 +1382,21 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - meths.input_mouse('right', 'press', '', 4, 9, 1) - meths.input_mouse('right', 'release', '', 4, 9, 1) + api.nvim_input_mouse('right', 'press', '', 4, 9, 1) + api.nvim_input_mouse('right', 'release', '', 4, 9, 1) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2808,37 +1413,24 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 6 {21: Copy }| ]], float_pos={ - [6] = {{id = -1}, "SW", 4, 9, 0, false, 250}; + [6] = {-1, "SW", 4, 9, 0, false, 250}; }} feed('<Down><CR>') screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -2855,35 +1447,22 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - eq('eiusmo', funcs.getreg('"')) + eq('eiusmo', fn.getreg('"')) screen:try_resize_grid(4, 7, 11) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -2901,35 +1480,22 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - funcs.setreg('"', '') - meths.input_mouse('left', 'press', '2', 4, 9, 1) + fn.setreg('"', '') + api.nvim_input_mouse('left', 'press', '2', 4, 9, 1) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2947,34 +1513,21 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - meths.input_mouse('right', 'press', '', 4, 9, 1) - meths.input_mouse('right', 'release', '', 4, 9, 1) + api.nvim_input_mouse('right', 'press', '', 4, 9, 1) + api.nvim_input_mouse('right', 'release', '', 4, 9, 1) screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {7:-- VISUAL --} | ## grid 4 @@ -2992,37 +1545,24 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 6 {21: Copy }| ]], float_pos={ - [6] = {{id = -1}, "NW", 4, 10, 0, false, 250}; + [6] = {-1, "NW", 4, 10, 0, false, 250}; }} feed('<Down><CR>') screen:expect{grid=[[ ## grid 1 - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| - [5:------------------------------]│[2:----------------------]| + [5:------------------------------]│[2:----------------------]|*5 {12:[No Name] [+] [No Name] [+] }| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] [+] }| [3:-----------------------------------------------------]| ## grid 2 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 @@ -3040,11 +1580,9 @@ describe('ext_multigrid', function() ## grid 5 some text | to be clicked | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ]]} - eq('eiusmo', funcs.getreg('"')) + eq('eiusmo', fn.getreg('"')) end) it('supports mouse drag with mouse=a', function() @@ -3055,54 +1593,29 @@ describe('ext_multigrid', function() command('enew') feed('ifoo\nbar<esc>') - meths.input_mouse('left', 'press', '', 5, 0, 0) + api.nvim_input_mouse('left', 'press', '', 5, 0, 0) poke_eventloop() - meths.input_mouse('left', 'drag', '', 5, 1, 2) + api.nvim_input_mouse('left', 'drag', '', 5, 1, 2) screen:expect{grid=[[ ## grid 1 - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| - [4:--------------------------]│[5:--------------------------]| + [4:--------------------------]│[5:--------------------------]|*6 [4:--------------------------]│{11:[No Name] [+] }| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| - [4:--------------------------]│[2:--------------------------]| + [4:--------------------------]│[2:--------------------------]|*5 {12:[No Name] [No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 {7:-- VISUAL --} | ## grid 4 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 ## grid 5 {20:foo} | {20:ba}^r | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]} end) @@ -3110,25 +1623,16 @@ describe('ext_multigrid', function() screen:try_resize(48, 8) screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] }| [3:------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ]], win_viewport={ - [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} }} insert([[ Lorem ipsum dolor sit amet, consectetur @@ -3145,12 +1649,7 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3163,19 +1662,14 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, + [2] = {win = 1000, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, }} feed('<c-u>') screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3188,18 +1682,15 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 2, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 2}, + [2] = {win = 1000, topline = 2, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 2}, }} command("split") screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3212,19 +1703,16 @@ describe('ext_multigrid', function() reprehenderit in voluptate velit esse cillum | ^dolore eu fugiat nulla pariatur. Excepteur sint | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, - [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 5}, + [2] = {win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = 1001, topline = 5, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 5}, }} feed("b") screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3237,19 +1725,16 @@ describe('ext_multigrid', function() reprehenderit in voluptate velit esse ^cillum | dolore eu fugiat nulla pariatur. Excepteur sint | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, - [4] = {win = {id = 1001}, topline = 5, botline = 9, curline = 6, curcol = 38, linecount = 11, sum_scroll_delta = 5}, + [2] = {win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = 1001, topline = 5, botline = 9, curline = 6, curcol = 38, linecount = 11, sum_scroll_delta = 5}, }} feed("2k") screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3262,20 +1747,17 @@ describe('ext_multigrid', function() ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, - [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, + [2] = {win = 1000, topline = 6, botline = 9, curline = 7, curcol = 0, linecount = 11, sum_scroll_delta = 6}, + [4] = {win = 1001, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, }} -- handles non-current window - meths.win_set_cursor(1000, {1, 10}) + api.nvim_win_set_cursor(1000, {1, 10}) screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3288,20 +1770,17 @@ describe('ext_multigrid', function() ea commodo consequat. Duis aute irure dolor in | reprehenderit in voluptate velit esse cillum | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, - [4] = {win = {id = 1001}, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, + [2] = {win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = 1001, topline = 4, botline = 8, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, }} -- sum_scroll_delta works with folds feed('zfj') screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3314,19 +1793,16 @@ describe('ext_multigrid', function() reprehenderit in voluptate velit esse cillum | dolore eu fugiat nulla pariatur. Excepteur sint | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, - [4] = {win = {id = 1001}, topline = 4, botline = 9, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, + [2] = {win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = 1001, topline = 4, botline = 9, curline = 4, curcol = 38, linecount = 11, sum_scroll_delta = 4}, }} feed('<c-e>') screen:expect{grid=[[ ## grid 1 - [4:------------------------------------------------]| - [4:------------------------------------------------]| - [4:------------------------------------------------]| + [4:------------------------------------------------]|*3 {11:[No Name] [+] }| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*2 {12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3339,19 +1815,14 @@ describe('ext_multigrid', function() dolore eu fugiat nulla pariatur. Excepteur sint | occaecat cupidatat non proident, sunt in culpa | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, - [4] = {win = {id = 1001}, topline = 6, botline = 10, curline = 6, curcol = 0, linecount = 11, sum_scroll_delta = 5}, + [2] = {win = 1000, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}, + [4] = {win = 1001, topline = 6, botline = 10, curline = 6, curcol = 0, linecount = 11, sum_scroll_delta = 5}, }} command('close | 21vsplit | setlocal number smoothscroll') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3371,19 +1842,14 @@ describe('ext_multigrid', function() {19: } sed do eiusmod t| {19: }empor | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 0, botline = 3, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; }} feed('5<C-E>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3403,19 +1869,14 @@ describe('ext_multigrid', function() {19: 4 }Ut enim ad minim | {19: }veniam, quis n{1:@@@}| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 5}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 5}; }} feed('<C-Y>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3435,19 +1896,14 @@ describe('ext_multigrid', function() {19: }na aliqua. | {19: 4 }Ut enim ad min{1:@@@}| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; }} command('set cpoptions+=n') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3467,19 +1923,14 @@ describe('ext_multigrid', function() liqua. | {19: 4 }Ut enim ad min{1:@@@}| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 1, botline = 4, curline = 1, curcol = 38, linecount = 11, sum_scroll_delta = 4}; }} feed('4<C-E>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3499,19 +1950,14 @@ describe('ext_multigrid', function() mco laboris nisi ut a| liquip ex | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 2, botline = 6, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 2, botline = 6, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; }} feed('2<C-Y>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3531,19 +1977,14 @@ describe('ext_multigrid', function() veniam, quis nostrud | {19: 5 }exercitation u{1:@@@}| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; }} command('setlocal numberwidth=12') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3563,19 +2004,14 @@ describe('ext_multigrid', function() d minim veniam, quis | nostrud | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 6}; }} feed('2<C-E>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3595,19 +2031,14 @@ describe('ext_multigrid', function() {19: 5 }exercitat| ion ullamco labori{1:@@@}| ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 2, botline = 5, curline = 2, curcol = 43, linecount = 11, sum_scroll_delta = 8}; }} feed('<C-E>') screen:expect{grid=[[ ## grid 1 - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| - [5:---------------------]│[2:--------------------------]| + [5:---------------------]│[2:--------------------------]|*6 {11:[No Name] [+] }{12:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3627,8 +2058,8 @@ describe('ext_multigrid', function() ion ullamco laboris n| isi ut aliquip ex | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; - [5] = {win = {id = 1002}, topline = 3, botline = 6, curline = 3, curcol = 36, linecount = 11, sum_scroll_delta = 9}; + [2] = {win = 1000, topline = 0, botline = 4, curline = 0, curcol = 10, linecount = 11, sum_scroll_delta = 0}; + [5] = {win = 1002, topline = 3, botline = 6, curline = 3, curcol = 36, linecount = 11, sum_scroll_delta = 9}; }} end) @@ -3637,18 +2068,7 @@ describe('ext_multigrid', function() command('edit test/functional/fixtures/bigfile.txt') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3667,23 +2087,12 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; }} feed('G') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3702,23 +2111,12 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 30580, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30580}; + [2] = {win = 1000, topline = 30580, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30580}; }} feed('gg') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3737,23 +2135,12 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 13, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; }} command('setlocal wrap') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3772,23 +2159,12 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; }} feed('G') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3807,23 +2183,12 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 30586, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30588}; + [2] = {win = 1000, topline = 30586, botline = 30592, curline = 30591, curcol = 0, linecount = 30592, sum_scroll_delta = 30588}; }} feed('gg') screen:expect{grid=[[ ## grid 1 - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*12 {11:test/functional/fixtures/bigfile.txt }| [3:-----------------------------------------------------]| ## grid 2 @@ -3842,7 +2207,7 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 10, curline = 0, curcol = 0, linecount = 30592, sum_scroll_delta = 0}; }} end) @@ -3850,25 +2215,16 @@ describe('ext_multigrid', function() screen:try_resize(48, 8) screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] }| [3:------------------------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ]], win_viewport={ - [2] = {win = { id = 1000 }, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0} }} insert([[ Lorem ipsum dolor sit amet, consectetur @@ -3885,12 +2241,7 @@ describe('ext_multigrid', function() screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3903,21 +2254,16 @@ describe('ext_multigrid', function() ## grid 3 | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, + [2] = {win = 1000, topline = 5, botline = 11, curline = 10, curcol = 7, linecount = 11, sum_scroll_delta = 5}, }} - meths.input_mouse('left', 'press', '', 1,5, 1) + api.nvim_input_mouse('left', 'press', '', 1,5, 1) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 1) + api.nvim_input_mouse('left', 'drag', '', 1, 6, 1) screen:expect{grid=[[ ## grid 1 - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| - [2:------------------------------------------------]| + [2:------------------------------------------------]|*6 {11:[No Name] [+] }| [3:------------------------------------------------]| ## grid 2 @@ -3930,7 +2276,7 @@ describe('ext_multigrid', function() ## grid 3 {7:-- VISUAL --} | ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11, sum_scroll_delta = 6}, + [2] = {win = 1000, topline = 6, botline = 12, curline = 10, curcol = 1, linecount = 11, sum_scroll_delta = 6}, }} end) @@ -3938,38 +2284,22 @@ describe('ext_multigrid', function() command('split') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} -- XXX: hack to get notifications. Could use next_msg() also. @@ -3983,256 +2313,155 @@ describe('ext_multigrid', function() command('setlocal winbar=very%=bar') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 {7:very bar}| ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} eq({}, win_pos) command('setlocal winbar=') screen:expect{grid=[[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; - [4] = {win = {id = 1001}, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [2] = {win = 1000, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; + [4] = {win = 1001, topline = 0, botline = 2, curline = 0, curcol = 0, linecount = 1, sum_scroll_delta = 0}; }} eq({}, win_pos) end) it('with winbar dragging statusline with mouse works correctly', function() - meths.set_option_value('winbar', 'Set Up The Bars', {}) + api.nvim_set_option_value('winbar', 'Set Up The Bars', {}) command('split') screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*6 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 {7:Set Up The Bars }| | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 | ## grid 4 {7:Set Up The Bars }| ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ]]) - meths.input_mouse('left', 'press', '', 1, 6, 20) + api.nvim_input_mouse('left', 'press', '', 1, 6, 20) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 7, 20) + api.nvim_input_mouse('left', 'drag', '', 1, 7, 20) screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*7 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*4 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 {7:Set Up The Bars }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 | ## grid 4 {7:Set Up The Bars }| ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ]]) - meths.input_mouse('left', 'drag', '', 1, 4, 20) + api.nvim_input_mouse('left', 'drag', '', 1, 4, 20) screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*7 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 {7:Set Up The Bars }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 {7:Set Up The Bars }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]]) - meths.input_mouse('left', 'press', '', 1, 12, 10) + api.nvim_input_mouse('left', 'press', '', 1, 12, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 10, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 10, 10) screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*5 {12:[No Name] }| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| - [3:-----------------------------------------------------]| + [3:-----------------------------------------------------]|*3 ## grid 2 {7:Set Up The Bars }| | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 - | - | - | + |*3 ## grid 4 {7:Set Up The Bars }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]]) - eq(3, meths.get_option_value('cmdheight', {})) + eq(3, api.nvim_get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 1, 12, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 12, 10) screen:expect([[ ## grid 1 - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| - [4:-----------------------------------------------------]| + [4:-----------------------------------------------------]|*4 {11:[No Name] }| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| - [2:-----------------------------------------------------]| + [2:-----------------------------------------------------]|*7 {12:[No Name] }| [3:-----------------------------------------------------]| ## grid 2 {7:Set Up The Bars }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ## grid 3 | ## grid 4 {7:Set Up The Bars }| ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) end) diff --git a/test/functional/ui/options_spec.lua b/test/functional/ui/options_spec.lua index 2c649709c6..98af82a7c5 100644 --- a/test/functional/ui/options_spec.lua +++ b/test/functional/ui/options_spec.lua @@ -9,45 +9,48 @@ local eval = helpers.eval describe('UI receives option updates', function() local screen - local function reset(opts, ...) + local function reset(screen_opts, clear_opts) local defaults = { - ambiwidth='single', - arabicshape=true, - emoji=true, - guifont='', - guifontwide='', - linespace=0, - pumblend=0, - mousefocus=false, - mousehide=true, - mousemoveevent=false, - showtabline=1, - termguicolors=false, - termsync=true, - ttimeout=true, - ttimeoutlen=50, - verbose=0, - ext_cmdline=false, - ext_popupmenu=false, - ext_tabline=false, - ext_wildmenu=false, - ext_linegrid=false, - ext_hlstate=false, - ext_multigrid=false, - ext_messages=false, - ext_termcolors=false, + ambiwidth = 'single', + arabicshape = true, + emoji = true, + guifont = '', + guifontwide = '', + linespace = 0, + pumblend = 0, + mousefocus = false, + mousehide = true, + mousemoveevent = false, + showtabline = 1, + termguicolors = false, + termsync = true, + ttimeout = true, + ttimeoutlen = 50, + verbose = 0, + ext_cmdline = false, + ext_popupmenu = false, + ext_tabline = false, + ext_wildmenu = false, + ext_linegrid = false, + ext_hlstate = false, + ext_multigrid = false, + ext_messages = false, + ext_termcolors = false, } - clear(...) - screen = Screen.new(20,5) - screen:attach(opts) + clear_opts = shallowcopy(clear_opts or {}) + clear_opts.args_rm = clear_opts.args_rm or {} + table.insert(clear_opts.args_rm or {}, '--cmd') + clear(clear_opts) + screen = Screen.new(20, 5) + screen:attach(screen_opts) -- NB: UI test suite can be run in both "linegrid" and legacy grid mode. -- In both cases check that the received value is the one requested. defaults.ext_linegrid = screen._options.ext_linegrid or false return defaults end - it("for defaults", function() + it('for defaults', function() local expected = reset() screen:expect(function() eq(expected, screen.options) @@ -55,9 +58,9 @@ describe('UI receives option updates', function() end) it('on attach #11372', function() - clear{args_rm={'--headless'}} + clear { args_rm = { '--headless' } } local evs = {} - screen = Screen.new(20,5) + screen = Screen.new(20, 5) -- Override mouse_on/mouse_off handlers. function screen:_handle_mouse_on() table.insert(evs, 'mouse_on') @@ -67,109 +70,109 @@ describe('UI receives option updates', function() end screen:attach() screen:expect(function() - eq({'mouse_on'}, evs) + eq({ 'mouse_on' }, evs) end) - command("set mouse=") + command('set mouse=') screen:expect(function() - eq({'mouse_on', 'mouse_off'}, evs) + eq({ 'mouse_on', 'mouse_off' }, evs) end) - command("set mouse&") + command('set mouse&') screen:expect(function() - eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs) + eq({ 'mouse_on', 'mouse_off', 'mouse_on' }, evs) end) screen:detach() - eq({'mouse_on', 'mouse_off', 'mouse_on'}, evs) + eq({ 'mouse_on', 'mouse_off', 'mouse_on' }, evs) screen:attach() screen:expect(function() - eq({'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on'}, evs) + eq({ 'mouse_on', 'mouse_off', 'mouse_on', 'mouse_on' }, evs) end) end) - it("when setting options", function() + it('when setting options', function() local expected = reset() local defaults = shallowcopy(expected) - command("set termguicolors") + command('set termguicolors') expected.termguicolors = true screen:expect(function() eq(expected, screen.options) end) - command("set pumblend=50") + command('set pumblend=50') expected.pumblend = 50 screen:expect(function() - eq(expected, screen.options) + eq(expected, screen.options) end) -- check handling of out-of-bounds value - command("set pumblend=-1") + command('set pumblend=-1') expected.pumblend = 0 screen:expect(function() - eq(expected, screen.options) + eq(expected, screen.options) end) - command("set guifont=Comic\\ Sans") - expected.guifont = "Comic Sans" + command('set guifont=Comic\\ Sans') + expected.guifont = 'Comic Sans' screen:expect(function() eq(expected, screen.options) end) - command("set showtabline=0") + command('set showtabline=0') expected.showtabline = 0 screen:expect(function() eq(expected, screen.options) end) - command("set linespace=13") + command('set linespace=13') expected.linespace = 13 screen:expect(function() eq(expected, screen.options) end) - command("set linespace=-11") + command('set linespace=-11') expected.linespace = -11 screen:expect(function() eq(expected, screen.options) end) - command("set mousefocus") + command('set mousefocus') expected.mousefocus = true screen:expect(function() eq(expected, screen.options) end) - command("set nomousehide") + command('set nomousehide') expected.mousehide = false screen:expect(function() eq(expected, screen.options) end) - command("set mousemoveevent") + command('set mousemoveevent') expected.mousemoveevent = true screen:expect(function() eq(expected, screen.options) end) - command("set nottimeout") + command('set nottimeout') expected.ttimeout = false screen:expect(function() eq(expected, screen.options) end) - command("set ttimeoutlen=100") + command('set ttimeoutlen=100') expected.ttimeoutlen = 100 screen:expect(function() eq(expected, screen.options) end) - command("set all&") + command('set all&') screen:expect(function() eq(defaults, screen.options) end) end) it('with UI extensions', function() - local expected = reset({ext_cmdline=true, ext_wildmenu=true}) + local expected = reset({ ext_cmdline = true, ext_wildmenu = true }) expected.ext_cmdline = true expected.ext_wildmenu = true @@ -191,37 +194,43 @@ describe('UI receives option updates', function() end) local function startup_test(headless) - local expected = reset(nil, {args_rm=(headless and {} or {'--headless'}), - args={'--cmd', 'set guifont=Comic\\ Sans\\ 12'}}) - expected.guifont = "Comic Sans 12" + local expected = reset(nil, { + args_rm = (headless and {} or { '--headless' }), + args = { '--cmd', 'set guifont=Comic\\ Sans\\ 12' }, + }) + expected.guifont = 'Comic Sans 12' screen:expect(function() eq(expected, screen.options) end) end - it('from startup options with --headless', function() startup_test(true) end) - it('from startup options with --embed', function() startup_test(false) end) + it('from startup options with --headless', function() + startup_test(true) + end) + it('from startup options with --embed', function() + startup_test(false) + end) end) describe('UI can set terminal option', function() local screen before_each(function() -- by default we implicitly "--cmd 'set bg=light'" which ruins everything - clear{args_rm={'--cmd'}} - screen = Screen.new(20,5) + clear { args_rm = { '--cmd' } } + screen = Screen.new(20, 5) end) it('term_name', function() eq('nvim', eval '&term') - screen:attach {term_name='xterm'} + screen:attach { term_name = 'xterm' } eq('xterm', eval '&term') end) it('term_colors', function() eq('256', eval '&t_Co') - screen:attach {term_colors=8} + screen:attach { term_colors = 8 } eq('8', eval '&t_Co') end) end) diff --git a/test/functional/ui/output_spec.lua b/test/functional/ui/output_spec.lua index 7b93b74eac..5e340af89c 100644 --- a/test/functional/ui/output_spec.lua +++ b/test/functional/ui/output_spec.lua @@ -15,38 +15,42 @@ local set_shell_powershell = helpers.set_shell_powershell local skip = helpers.skip local is_os = helpers.is_os -clear() -- for has_powershell() +clear() -- for has_powershell() -describe("shell command :!", function() +describe('shell command :!', function() local screen before_each(function() clear() - screen = child_session.screen_setup(0, '["'..helpers.nvim_prog.. - '", "-u", "NONE", "-i", "NONE", "--cmd", "'..helpers.nvim_set..'"]') + screen = child_session.setup_child_nvim({ + '-u', + 'NONE', + '-i', + 'NONE', + '--cmd', + 'colorscheme vim', + '--cmd', + helpers.nvim_set .. ' notermguicolors', + }) screen:expect([[ {1: } | - {4:~ }| - {4:~ }| - {4:~ }| - {4:~ }| + {4:~ }|*4 | {3:-- TERMINAL --} | ]]) end) after_each(function() - child_session.feed_data("\3") -- Ctrl-C + child_session.feed_data('\3') -- Ctrl-C end) - it("displays output without LF/EOF. #4646 #4569 #3772", function() + it('displays output without LF/EOF. #4646 #4569 #3772', function() skip(is_os('win')) -- NOTE: We use a child nvim (within a :term buffer) -- to avoid triggering a UI flush. - child_session.feed_data(":!printf foo; sleep 200\n") + child_session.feed_data(':!printf foo; sleep 200\n') screen:expect([[ | - {4:~ }| - {4:~ }| + {4:~ }|*2 {5: }| :!printf foo; sleep 200 | foo | @@ -54,18 +58,19 @@ describe("shell command :!", function() ]]) end) - it("throttles shell-command output greater than ~10KB", function() + it('throttles shell-command output greater than ~10KB', function() skip(is_os('openbsd'), 'FIXME #10804') skip(is_os('win')) - child_session.feed_data((":!%s REP 30001 foo\n"):format(testprg('shell-test'))) + child_session.feed_data((':!%s REP 30001 foo\n'):format(testprg('shell-test'))) -- If we observe any line starting with a dot, then throttling occurred. -- Avoid false failure on slow systems. - screen:expect{any="\n%.", timeout=20000} + screen:expect { any = '\n%.', timeout = 20000 } -- Final chunk of output should always be displayed, never skipped. -- (Throttling is non-deterministic, this test is merely a sanity check.) - screen:expect([[ + screen:expect( + [[ 29997: foo | 29998: foo | 29999: foo | @@ -73,27 +78,29 @@ describe("shell command :!", function() | {10:Press ENTER or type command to continue}{1: } | {3:-- TERMINAL --} | - ]], { - -- test/functional/helpers.lua defaults to background=light. - [1] = {reverse = true}, - [3] = {bold = true}, - [10] = {foreground = 2}, - }) + ]], + { + -- test/functional/helpers.lua defaults to background=light. + [1] = { reverse = true }, + [3] = { bold = true }, + [10] = { foreground = 2 }, + } + ) end) end) -describe("shell command :!", function() +describe('shell command :!', function() before_each(function() clear() end) - it("cat a binary file #4142", function() + it('cat a binary file #4142', function() feed(":exe 'silent !cat '.shellescape(v:progpath)<CR>") assert_alive() end) it([[display \x08 char #4142]], function() - feed(":silent !echo \08<CR>") + feed(':silent !echo \08<CR>') assert_alive() end) @@ -101,32 +108,37 @@ describe("shell command :!", function() skip(is_os('win'), 'missing printf') local screen = Screen.new(50, 4) screen:set_default_attr_ids { - [1] = {bold = true, reverse = true}; - [2] = {bold = true, foreground = Screen.colors.SeaGreen}; - [3] = {foreground = Screen.colors.Blue}; + [1] = { bold = true, reverse = true }, + [2] = { bold = true, foreground = Screen.colors.SeaGreen }, + [3] = { foreground = Screen.colors.Blue }, } screen:attach() -- Print TAB chars. #2958 feed([[:!printf '1\t2\t3'<CR>]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }| :!printf '1\t2\t3' | 1 2 3 | {2:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed([[<CR>]]) -- Print BELL control code. #4338 screen.bell = false feed([[:!printf '\007\007\007\007text'<CR>]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: }| :!printf '\007\007\007\007text' | text | {2:Press ENTER or type command to continue}^ | - ]], condition=function() - eq(true, screen.bell) - end} + ]], + condition = function() + eq(true, screen.bell) + end, + } feed([[<CR>]]) -- Print BS control code. @@ -143,8 +155,7 @@ describe("shell command :!", function() feed([[:!printf '\n'<CR>]]) screen:expect([[ :!printf '\n' | - | - | + |*2 {2:Press ENTER or type command to continue}^ | ]]) feed([[<CR>]]) @@ -158,12 +169,12 @@ describe("shell command :!", function() write_file('bang_filter_spec/f1', 'f1') write_file('bang_filter_spec/f2', 'f2') write_file('bang_filter_spec/f3', 'f3') - screen = Screen.new(53,10) + screen = Screen.new(53, 10) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Blue1}, - [3] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [4] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Blue1 }, + [3] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [4] = { bold = true, reverse = true }, }) screen:attach() end) @@ -173,19 +184,19 @@ describe("shell command :!", function() end) it("doesn't truncate Last line of shell output #3269", function() - command(is_os('win') - and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]] - or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]]) - local result = (is_os('win') - and [[:!dir /b bang_filter_spec]] - or [[:!ls bang_filter_spec ]]) + command( + is_os('win') and [[nnoremap <silent>\l :!dir /b bang_filter_spec<cr>]] + or [[nnoremap <silent>\l :!ls bang_filter_spec<cr>]] + ) + local result = ( + is_os('win') and [[:!dir /b bang_filter_spec]] or [[:!ls bang_filter_spec ]] + ) feed([[\l]]) screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {4: }| - ]]..result..[[ | + ]] .. result .. [[ | f1 | f2 | f3 | @@ -197,7 +208,8 @@ describe("shell command :!", function() it('handles binary and multibyte data', function() feed_command('!cat test/functional/fixtures/shell_data.txt') screen.bell = false - screen:expect{grid=[[ + screen:expect { + grid = [[ | {1:~ }| {4: }| @@ -208,20 +220,22 @@ describe("shell command :!", function() t {2:<ff>} | | {3:Press ENTER or type command to continue}^ | - ]], condition=function() - eq(true, screen.bell) - end} + ]], + condition = function() + eq(true, screen.bell) + end, + } end) it('handles multibyte sequences split over buffer boundaries', function() - command('cd '..nvim_dir) + command('cd ' .. nvim_dir) local cmd = is_os('win') and '!shell-test UTF-8 ' or '!./shell-test UTF-8' feed_command(cmd) -- Note: only the first example of split composed char works screen:expect([[ | {4: }| - :]]..cmd..[[ | + :]] .. cmd .. [[ | å | ref: å̲ | 1: å̲ | diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index a6cd216d84..1f0d20f66d 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -4,10 +4,10 @@ local assert_alive = helpers.assert_alive local clear, feed = helpers.clear, helpers.feed local source = helpers.source local insert = helpers.insert -local meths = helpers.meths +local api = helpers.api local async_meths = helpers.async_meths local command = helpers.command -local funcs = helpers.funcs +local fn = helpers.fn local eq = helpers.eq local pcall_err = helpers.pcall_err local exec_lua = helpers.exec_lua @@ -18,16 +18,16 @@ describe('ui/ext_popupmenu', function() before_each(function() clear() screen = Screen.new(60, 8) - screen:attach({rgb=true, ext_popupmenu=true}) + screen:attach({ rgb = true, ext_popupmenu = true }) screen:set_default_attr_ids({ - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {bold = true}, - [3] = {reverse = true}, - [4] = {bold = true, reverse = true}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen}, - [6] = {background = Screen.colors.WebGray}, - [7] = {background = Screen.colors.LightMagenta}, - [8] = {foreground = Screen.colors.Red}, + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { bold = true, reverse = true }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen }, + [6] = { background = Screen.colors.WebGray }, + [7] = { background = Screen.colors.LightMagenta }, + [8] = { foreground = Screen.colors.Red }, }) source([[ function! TestComplete() abort @@ -38,447 +38,399 @@ describe('ui/ext_popupmenu', function() end) local expected = { - {'fo', 'x', 'the foo', 'foo-y'}, - {'bar', '', '', ''}, - {'spam', '', '', ''}, + { 'fo', 'x', 'the foo', 'foo-y' }, + { 'bar', '', '', '' }, + { 'spam', '', '', '' }, } it('works', function() feed('o<C-r>=TestComplete()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } feed('<c-p>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=-1, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = -1, + anchor = { 1, 1, 0 }, + }, + } -- down moves the selection in the menu, but does not insert anything feed('<down><down>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=1, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 1, + anchor = { 1, 1, 0 }, + }, + } feed('<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | bar^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]]} + ]], + } end) it('can be controlled by API', function() feed('o<C-r>=TestComplete()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(1,false,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(1, false, false, {}) + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=1, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(2,true,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = 1, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(2, true, false, {}) + screen:expect { + grid = [[ | spam^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=2, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 2, + anchor = { 1, 1, 0 }, + }, + } - meths.select_popupmenu_item(0,true,true,{}) + api.nvim_select_popupmenu_item(0, true, true, {}) screen:expect([[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) - feed('<c-w><C-r>=TestComplete()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(-1,false,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(-1, false, false, {}) + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=-1, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(1,true,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = -1, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(1, true, false, {}) + screen:expect { + grid = [[ | bar^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=1, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(-1,true,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = 1, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(-1, true, false, {}) + screen:expect { + grid = [[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=-1, - anchor={1,1,0}, - }} - - meths.select_popupmenu_item(0,true,false,{}) - screen:expect{grid=[[ + ]], + popupmenu = { + items = expected, + pos = -1, + anchor = { 1, 1, 0 }, + }, + } + + api.nvim_select_popupmenu_item(0, true, false, {}) + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } - meths.select_popupmenu_item(-1,true,true,{}) + api.nvim_select_popupmenu_item(-1, true, true, {}) screen:expect([[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) command('set wildmenu') command('set wildoptions=pum') local expected_wildpum = { - { "define", "", "", "" }, - { "jump", "", "", "" }, - { "list", "", "", "" }, - { "place", "", "", "" }, - { "undefine", "", "", "" }, - { "unplace", "", "", "" }, + { 'define', '', '', '' }, + { 'jump', '', '', '' }, + { 'list', '', '', '' }, + { 'place', '', '', '' }, + { 'undefine', '', '', '' }, + { 'unplace', '', '', '' }, } feed('<Esc>:sign <Tab>') - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign define^ | - ]], popupmenu = { - items = expected_wildpum, - pos = 0, - anchor = { 1, 7, 6 }, - }}) - - meths.select_popupmenu_item(-1, true, false, {}) - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ]], + popupmenu = { + items = expected_wildpum, + pos = 0, + anchor = { 1, 7, 6 }, + }, + }) + + api.nvim_select_popupmenu_item(-1, true, false, {}) + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign ^ | - ]], popupmenu = { - items = expected_wildpum, - pos = -1, - anchor = { 1, 7, 6 }, - }}) - - meths.select_popupmenu_item(5, true, false, {}) - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ]], + popupmenu = { + items = expected_wildpum, + pos = -1, + anchor = { 1, 7, 6 }, + }, + }) + + api.nvim_select_popupmenu_item(5, true, false, {}) + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign unplace^ | - ]], popupmenu = { - items = expected_wildpum, - pos = 5, - anchor = { 1, 7, 6 }, - }}) - - meths.select_popupmenu_item(-1, true, true, {}) - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ]], + popupmenu = { + items = expected_wildpum, + pos = 5, + anchor = { 1, 7, 6 }, + }, + }) + + api.nvim_select_popupmenu_item(-1, true, true, {}) + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign ^ | - ]]}) + ]], + }) feed('<Tab>') - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign define^ | - ]], popupmenu = { - items = expected_wildpum, - pos = 0, - anchor = { 1, 7, 6 }, - }}) - - meths.select_popupmenu_item(5, true, true, {}) - screen:expect({grid = [[ - | - | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + ]], + popupmenu = { + items = expected_wildpum, + pos = 0, + anchor = { 1, 7, 6 }, + }, + }) + + api.nvim_select_popupmenu_item(5, true, true, {}) + screen:expect({ + grid = [[ + |*2 + {1:~ }|*5 :sign unplace^ | - ]]}) + ]], + }) local function test_pum_select_mappings() screen:set_option('ext_popupmenu', true) feed('<Esc>A<C-r>=TestComplete()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } feed('<f1>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | spam^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=2, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 2, + anchor = { 1, 1, 0 }, + }, + } feed('<f2>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | spam^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=-1, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = -1, + anchor = { 1, 1, 0 }, + }, + } feed('<f3>') screen:expect([[ | bar^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) feed('<Esc>:sign <Tab>') - screen:expect({grid = [[ + screen:expect({ + grid = [[ | bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :sign define^ | - ]], popupmenu = { - items = expected_wildpum, - pos = 0, - anchor = { 1, 7, 6 }, - }}) + ]], + popupmenu = { + items = expected_wildpum, + pos = 0, + anchor = { 1, 7, 6 }, + }, + }) feed('<f1>') - screen:expect({grid = [[ + screen:expect({ + grid = [[ | bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :sign list^ | - ]], popupmenu = { - items = expected_wildpum, - pos = 2, - anchor = { 1, 7, 6 }, - }}) + ]], + popupmenu = { + items = expected_wildpum, + pos = 2, + anchor = { 1, 7, 6 }, + }, + }) feed('<f2>') - screen:expect({grid = [[ + screen:expect({ + grid = [[ | bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :sign ^ | - ]], popupmenu = { - items = expected_wildpum, - pos = -1, - anchor = { 1, 7, 6 }, - }}) + ]], + popupmenu = { + items = expected_wildpum, + pos = -1, + anchor = { 1, 7, 6 }, + }, + }) feed('<f3>') - screen:expect({grid = [[ + screen:expect({ + grid = [[ | bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :sign jump^ | - ]]}) + ]], + }) -- also should work for builtin popupmenu screen:set_option('ext_popupmenu', false) @@ -489,8 +441,7 @@ describe('ui/ext_popupmenu', function() {6:fo x the foo }{1: }| {7:bar }{1: }| {7:spam }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) @@ -501,8 +452,7 @@ describe('ui/ext_popupmenu', function() {7:fo x the foo }{1: }| {7:bar }{1: }| {6:spam }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) @@ -513,8 +463,7 @@ describe('ui/ext_popupmenu', function() {7:fo x the foo }{1: }| {7:bar }{1: }| {7:spam }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) @@ -522,11 +471,7 @@ describe('ui/ext_popupmenu', function() screen:expect([[ | bar^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) @@ -570,11 +515,7 @@ describe('ui/ext_popupmenu', function() screen:expect([[ | bar | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :sign jump^ | ]]) end @@ -602,8 +543,7 @@ describe('ui/ext_popupmenu', function() {6:aa }{1: }| {7:bb }{1: }| {7:cc }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- Keyword Local completion (^N^P) }{5:match 1 of 3} | ]]) @@ -614,8 +554,7 @@ describe('ui/ext_popupmenu', function() {7:aa }{1: }| {7:bb }{1: }| {6:cc }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- Keyword Local completion (^N^P) }{5:match 3 of 3} | ]]) @@ -626,8 +565,7 @@ describe('ui/ext_popupmenu', function() {7:aa }{1: }| {7:bb }{1: }| {7:cc }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- Keyword Local completion (^N^P) }{8:Back at original} | ]]) @@ -635,11 +573,7 @@ describe('ui/ext_popupmenu', function() screen:expect([[ aa bb cc | bb^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end) @@ -659,52 +593,49 @@ describe('ui/ext_popupmenu', function() it('can set pum height', function() source_complete_month() local month_expected = { - {'January', '', '', ''}, - {'February', '', '', ''}, - {'March', '', '', ''}, - {'April', '', '', ''}, - {'May', '', '', ''}, - {'June', '', '', ''}, - {'July', '', '', ''}, - {'August', '', '', ''}, - {'September', '', '', ''}, - {'October', '', '', ''}, - {'November', '', '', ''}, - {'December', '', '', ''}, + { 'January', '', '', '' }, + { 'February', '', '', '' }, + { 'March', '', '', '' }, + { 'April', '', '', '' }, + { 'May', '', '', '' }, + { 'June', '', '', '' }, + { 'July', '', '', '' }, + { 'August', '', '', '' }, + { 'September', '', '', '' }, + { 'October', '', '', '' }, + { 'November', '', '', '' }, + { 'December', '', '', '' }, } local pum_height = 6 feed('o<C-r>=TestCompleteMonth()<CR>') - meths.ui_pum_set_height(pum_height) + api.nvim_ui_pum_set_height(pum_height) feed('<PageDown>') -- pos becomes pum_height-2 because it is subtracting 2 to keep some -- context in ins_compl_key2count() - screen:expect{grid=[[ + screen:expect { + grid = [[ | January^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=month_expected, - pos=pum_height-2, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = month_expected, + pos = pum_height - 2, + anchor = { 1, 1, 0 }, + }, + } end) it('an error occurs if set 0 or less', function() - meths.ui_pum_set_height(1) - eq('Expected pum height > 0', - pcall_err(meths.ui_pum_set_height, 0)) + api.nvim_ui_pum_set_height(1) + eq('Expected pum height > 0', pcall_err(api.nvim_ui_pum_set_height, 0)) end) it('an error occurs when ext_popupmenu is false', function() - meths.ui_pum_set_height(1) + api.nvim_ui_pum_set_height(1) screen:set_option('ext_popupmenu', false) - eq('It must support the ext_popupmenu option', - pcall_err(meths.ui_pum_set_height, 1)) + eq('It must support the ext_popupmenu option', pcall_err(api.nvim_ui_pum_set_height, 1)) end) end) @@ -712,239 +643,205 @@ describe('ui/ext_popupmenu', function() it('can set pum bounds', function() source_complete_month() local month_expected = { - {'January', '', '', ''}, - {'February', '', '', ''}, - {'March', '', '', ''}, - {'April', '', '', ''}, - {'May', '', '', ''}, - {'June', '', '', ''}, - {'July', '', '', ''}, - {'August', '', '', ''}, - {'September', '', '', ''}, - {'October', '', '', ''}, - {'November', '', '', ''}, - {'December', '', '', ''}, + { 'January', '', '', '' }, + { 'February', '', '', '' }, + { 'March', '', '', '' }, + { 'April', '', '', '' }, + { 'May', '', '', '' }, + { 'June', '', '', '' }, + { 'July', '', '', '' }, + { 'August', '', '', '' }, + { 'September', '', '', '' }, + { 'October', '', '', '' }, + { 'November', '', '', '' }, + { 'December', '', '', '' }, } local pum_height = 6 feed('o<C-r>=TestCompleteMonth()<CR>') - meths.ui_pum_set_height(pum_height) + api.nvim_ui_pum_set_height(pum_height) -- set bounds w h r c - meths.ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4) + api.nvim_ui_pum_set_bounds(10.5, 5.2, 6.3, 7.4) feed('<PageDown>') -- pos becomes pum_height-2 because it is subtracting 2 to keep some -- context in ins_compl_key2count() - screen:expect{grid=[[ + screen:expect { + grid = [[ | January^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=month_expected, - pos=pum_height-2, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = month_expected, + pos = pum_height - 2, + anchor = { 1, 1, 0 }, + }, + } end) it('no error occurs if row or col set less than 0', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) - meths.ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0) - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0) + api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + api.nvim_ui_pum_set_bounds(1.0, 1.0, -1.0, 0.0) + api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, -1.0) end) it('an error occurs if width or height set 0 or less', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) - eq('Expected width > 0', - pcall_err(meths.ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0)) - eq('Expected height > 0', - pcall_err(meths.ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0)) + api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + eq('Expected width > 0', pcall_err(api.nvim_ui_pum_set_bounds, 0.0, 1.0, 1.0, 0.0)) + eq('Expected height > 0', pcall_err(api.nvim_ui_pum_set_bounds, 1.0, -1.0, 1.0, 0.0)) end) it('an error occurs when ext_popupmenu is false', function() - meths.ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) + api.nvim_ui_pum_set_bounds(1.0, 1.0, 0.0, 1.5) screen:set_option('ext_popupmenu', false) - eq('UI must support the ext_popupmenu option', - pcall_err(meths.ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5)) + eq( + 'UI must support the ext_popupmenu option', + pcall_err(api.nvim_ui_pum_set_bounds, 1.0, 1.0, 0.0, 1.5) + ) end) end) it('<PageUP>, <PageDown> works without ui_pum_set_height', function() source_complete_month() local month_expected = { - {'January', '', '', ''}, - {'February', '', '', ''}, - {'March', '', '', ''}, - {'April', '', '', ''}, - {'May', '', '', ''}, - {'June', '', '', ''}, - {'July', '', '', ''}, - {'August', '', '', ''}, - {'September', '', '', ''}, - {'October', '', '', ''}, - {'November', '', '', ''}, - {'December', '', '', ''}, + { 'January', '', '', '' }, + { 'February', '', '', '' }, + { 'March', '', '', '' }, + { 'April', '', '', '' }, + { 'May', '', '', '' }, + { 'June', '', '', '' }, + { 'July', '', '', '' }, + { 'August', '', '', '' }, + { 'September', '', '', '' }, + { 'October', '', '', '' }, + { 'November', '', '', '' }, + { 'December', '', '', '' }, } feed('o<C-r>=TestCompleteMonth()<CR>') feed('<PageDown>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | January^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=month_expected, - pos=3, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = month_expected, + pos = 3, + anchor = { 1, 1, 0 }, + }, + } feed('<PageUp>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | January^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=month_expected, - pos=0, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = month_expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } end) it('works with wildoptions=pum', function() - screen:try_resize(32,10) + screen:try_resize(32, 10) command('set wildmenu') command('set wildoptions=pum') local wild_expected = { - {'define', '', '', ''}, - {'jump', '', '', ''}, - {'list', '', '', ''}, - {'place', '', '', ''}, - {'undefine', '', '', ''}, - {'unplace', '', '', ''}, + { 'define', '', '', '' }, + { 'jump', '', '', '' }, + { 'list', '', '', '' }, + { 'place', '', '', '' }, + { 'undefine', '', '', '' }, + { 'unplace', '', '', '' }, } feed(':sign ') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign ^ | ]]) - eq(0, funcs.wildmenumode()) + eq(0, fn.wildmenumode()) feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign define^ | - ]], popupmenu={items=wild_expected, pos=0, anchor={1, 9, 6}}} - eq(1, funcs.wildmenumode()) + ]], + popupmenu = { items = wild_expected, pos = 0, anchor = { 1, 9, 6 } }, + } + eq(1, fn.wildmenumode()) feed('<left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign ^ | - ]], popupmenu={items=wild_expected, pos=-1, anchor={1, 9, 6}}} + ]], + popupmenu = { items = wild_expected, pos = -1, anchor = { 1, 9, 6 } }, + } feed('<left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign unplace^ | - ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}} + ]], + popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } }, + } feed('x') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign unplacex^ | ]]) feed('<esc>') -- #10042: make sure shift-tab also triggers the pum feed(':sign <S-tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign unplace^ | - ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}} + ]], + popupmenu = { items = wild_expected, pos = 5, anchor = { 1, 9, 6 } }, + } feed('<esc>') - eq(0, funcs.wildmenumode()) + eq(0, fn.wildmenumode()) -- check positioning with multibyte char in pattern - command("e långfile1") - command("sp långfile2") + command('e långfile1') + command('sp långfile2') feed(':b lå<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4:långfile2 }| | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:långfile1 }| :b långfile1^ | - ]], popupmenu={ - anchor = {1, 9, 3}, - items = {{"långfile1", "", "", "" }, {"långfile2", "", "", ""}}, - pos = 0, - }} - + ]], + popupmenu = { + anchor = { 1, 9, 3 }, + items = { { 'långfile1', '', '', '' }, { 'långfile2', '', '', '' } }, + pos = 0, + }, + } end) it('does not interfere with mousemodel=popup', function() @@ -957,68 +854,58 @@ describe('ui/ext_popupmenu', function() menu PopUp.baz :let g:menustr = 'baz'<CR> ]]) feed('o<C-r>=TestComplete()<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | foo^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=0, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = 0, + anchor = { 1, 1, 0 }, + }, + } feed('<c-p>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | - ]], popupmenu={ - items=expected, - pos=-1, - anchor={1,1,0}, - }} + ]], + popupmenu = { + items = expected, + pos = -1, + anchor = { 1, 1, 0 }, + }, + } feed('<esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | - ]]} + ]], + } feed('<RightMouse><0,0>') screen:expect([[ | {7:^foo } | {7:bar }{1: }| {7:baz }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) feed('<esc>') screen:expect([[ | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 | ]]) end) @@ -1030,51 +917,51 @@ describe("builtin popupmenu 'pumblend'", function() it('RGB-color', function() local screen = Screen.new(60, 14) screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow}, - [2] = {bold = true, reverse = true}, - [3] = {bold = true, foreground = Screen.colors.Brown}, - [4] = {foreground = Screen.colors.Blue1}, - [5] = {reverse = true}, - [6] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey45}, - [7] = {background = Screen.colors.Gray55, foreground = Screen.colors.Grey0}, - [8] = {background = tonumber('0x191919'), foreground = Screen.colors.Grey0}, - [9] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5')}, - [10] = {background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0}, - [11] = {foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true}, - [12] = {foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true}, - [13] = {background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0}, - [14] = {background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5')}, - [15] = {background = tonumber('0xffc1ff'), foreground = tonumber('0x080202')}, - [16] = {background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9')}, - [17] = {background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff')}, - [18] = {background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff')}, - [19] = {background = Screen.colors.Gray45, foreground = Screen.colors.Grey55}, - [20] = {bold = true}, - [21] = {bold = true, foreground = Screen.colors.SeaGreen4}, - [22] = {background = Screen.colors.WebGray}, - [23] = {background = Screen.colors.Grey0}, - [24] = {background = Screen.colors.LightMagenta}, - [25] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey25}, - [26] = {background = Screen.colors.Gray75, foreground = Screen.colors.Grey0}, - [27] = {background = Screen.colors.Gray50, foreground = Screen.colors.Grey0}, - [28] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f')}, - [29] = {background = tonumber('0xffddff'), foreground = Screen.colors.Grey0}, - [30] = {foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true}, - [31] = {foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true}, - [32] = {foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true}, - [33] = {background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0}, - [34] = {background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f')}, - [35] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a')}, - [36] = {background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294')}, - [37] = {background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff')}, - [38] = {background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff')}, - [39] = {background = Screen.colors.Grey0, foreground = tonumber('0xffddff')}, - [40] = {background = Screen.colors.Gray25, foreground = Screen.colors.Grey75}, - [41] = {background = tonumber('0xffddff'), foreground = tonumber('0x00003f')}, - [42] = {foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5')}, - [43] = {background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f')}, - [44] = {foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f')}, - [45] = {background = Screen.colors.WebGray, blend=0}, + [1] = { background = Screen.colors.Yellow }, + [2] = { bold = true, reverse = true }, + [3] = { bold = true, foreground = Screen.colors.Brown }, + [4] = { foreground = Screen.colors.Blue1 }, + [5] = { reverse = true }, + [6] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey45 }, + [7] = { background = Screen.colors.Gray55, foreground = Screen.colors.Grey0 }, + [8] = { background = tonumber('0x191919'), foreground = Screen.colors.Grey0 }, + [9] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8e5') }, + [10] = { background = tonumber('0xffc1ff'), foreground = Screen.colors.Grey0 }, + [11] = { foreground = tonumber('0xffc1ff'), background = tonumber('0xe5a8e5'), bold = true }, + [12] = { foreground = Screen.colors.Grey55, background = Screen.colors.Gray45, bold = true }, + [13] = { background = tonumber('0xffc1e5'), foreground = Screen.colors.Grey0 }, + [14] = { background = tonumber('0xffc1e5'), foreground = tonumber('0xe5a8e5') }, + [15] = { background = tonumber('0xffc1ff'), foreground = tonumber('0x080202') }, + [16] = { background = tonumber('0xffc1ff'), bold = true, foreground = tonumber('0xf6ace9') }, + [17] = { background = tonumber('0xffc1ff'), foreground = tonumber('0xe5a8ff') }, + [18] = { background = tonumber('0xe5a8e5'), foreground = tonumber('0xffc1ff') }, + [19] = { background = Screen.colors.Gray45, foreground = Screen.colors.Grey55 }, + [20] = { bold = true }, + [21] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + [22] = { background = Screen.colors.WebGray }, + [23] = { background = Screen.colors.Grey0 }, + [24] = { background = Screen.colors.LightMagenta }, + [25] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey25 }, + [26] = { background = Screen.colors.Gray75, foreground = Screen.colors.Grey0 }, + [27] = { background = Screen.colors.Gray50, foreground = Screen.colors.Grey0 }, + [28] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5d7f') }, + [29] = { background = tonumber('0xffddff'), foreground = Screen.colors.Grey0 }, + [30] = { foreground = tonumber('0xffddff'), background = tonumber('0x7f5d7f'), bold = true }, + [31] = { foreground = tonumber('0xffddff'), background = Screen.colors.Grey0, bold = true }, + [32] = { foreground = Screen.colors.Gray75, background = Screen.colors.Grey25, bold = true }, + [33] = { background = tonumber('0xffdd7f'), foreground = Screen.colors.Grey0 }, + [34] = { background = tonumber('0xffdd7f'), foreground = tonumber('0x7f5d7f') }, + [35] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0x290a0a') }, + [36] = { background = tonumber('0xffddff'), bold = true, foreground = tonumber('0xd27294') }, + [37] = { background = tonumber('0xffddff'), foreground = tonumber('0x7f5dff') }, + [38] = { background = tonumber('0x7f5d7f'), foreground = tonumber('0xffddff') }, + [39] = { background = Screen.colors.Grey0, foreground = tonumber('0xffddff') }, + [40] = { background = Screen.colors.Gray25, foreground = Screen.colors.Grey75 }, + [41] = { background = tonumber('0xffddff'), foreground = tonumber('0x00003f') }, + [42] = { foreground = tonumber('0x0c0c0c'), background = tonumber('0xe5a8e5') }, + [43] = { background = tonumber('0x7f5d7f'), bold = true, foreground = tonumber('0x3f3f3f') }, + [44] = { foreground = tonumber('0x3f3f3f'), background = tonumber('0x7f5d7f') }, + [45] = { background = Screen.colors.WebGray, blend = 0 }, }) screen:attach() command('syntax on') @@ -1168,7 +1055,7 @@ describe("builtin popupmenu 'pumblend'", function() {20:-- Keyword Local completion (^N^P) }{21:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Lorem ipsum d{1:ol}or sit amet, consectetur | adipisicing elit, sed do eiusmod tempor | @@ -1228,18 +1115,18 @@ describe("builtin popupmenu 'pumblend'", function() it('256-color (non-RGB)', function() local screen = Screen.new(60, 8) screen:set_default_attr_ids({ - [1] = {foreground = Screen.colors.Grey0, background = tonumber('0x000007')}, - [2] = {foreground = tonumber('0x000055'), background = tonumber('0x000007')}, - [3] = {foreground = tonumber('0x00008f'), background = Screen.colors.Grey0}, - [4] = {foreground = Screen.colors.Grey0, background = tonumber('0x0000e1')}, - [5] = {foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1')}, - [6] = {foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8')}, - [7] = {foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8')}, - [8] = {foreground = tonumber('0x00000c')}, - [9] = {bold = true}, - [10] = {foreground = tonumber('0x000002')}, + [1] = { foreground = Screen.colors.Grey0, background = tonumber('0x000007') }, + [2] = { foreground = tonumber('0x000055'), background = tonumber('0x000007') }, + [3] = { foreground = tonumber('0x00008f'), background = Screen.colors.Grey0 }, + [4] = { foreground = Screen.colors.Grey0, background = tonumber('0x0000e1') }, + [5] = { foreground = tonumber('0x0000d1'), background = tonumber('0x0000e1') }, + [6] = { foreground = Screen.colors.NavyBlue, background = tonumber('0x0000f8') }, + [7] = { foreground = tonumber('0x0000a5'), background = tonumber('0x0000f8') }, + [8] = { foreground = tonumber('0x00000c') }, + [9] = { bold = true }, + [10] = { foreground = tonumber('0x000002') }, }) - screen:attach({rgb=false}) + screen:attach({ rgb = false }) command('set notermguicolors pumblend=10') insert([[ Lorem ipsum dolor sit amet, consectetur @@ -1271,21 +1158,21 @@ describe('builtin popupmenu', function() screen = Screen.new(32, 20) screen:set_default_attr_ids({ -- popup selected item / scrollbar track - ['s'] = {background = Screen.colors.WebGray}, + ['s'] = { background = Screen.colors.WebGray }, -- popup non-selected item - ['n'] = {background = Screen.colors.LightMagenta}, + ['n'] = { background = Screen.colors.LightMagenta }, -- popup scrollbar knob - ['c'] = {background = Screen.colors.Grey0}, - [1] = {bold = true, foreground = Screen.colors.Blue}, - [2] = {bold = true}, - [3] = {reverse = true}, - [4] = {bold = true, reverse = true}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen}, - [6] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [7] = {background = Screen.colors.Yellow}, -- Search - [8] = {foreground = Screen.colors.Red}, + ['c'] = { background = Screen.colors.Grey0 }, + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { bold = true, reverse = true }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen }, + [6] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [7] = { background = Screen.colors.Yellow }, -- Search + [8] = { foreground = Screen.colors.Red }, }) - screen:attach({ext_multigrid=multigrid}) + screen:attach({ ext_multigrid = multigrid }) end) it('with preview-window above', function() @@ -1293,49 +1180,24 @@ describe('builtin popupmenu', function() feed('iaa bb cc dd ee ff gg hh ii jj<cr>') feed('<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| + [4:--------------------------------]|*8 {3:[No Name] [Preview][+] }| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*9 {4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 aa bb cc dd ee ff gg hh ii jj | aa^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 ## grid 3 {2:-- }{5:match 1 of 10} | ## grid 4 aa bb cc dd ee ff gg hh ii jj | aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 5 {s:aa }{c: }| {n:bb }{c: }| @@ -1345,19 +1207,16 @@ describe('builtin popupmenu', function() {n:ff }{c: }| {n:gg }{s: }| {n:hh }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 2, 2, 0, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 2, 2, 0, false, 100 }, + }, + } else screen:expect([[ aa bb cc dd ee ff gg hh ii jj | aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {3:[No Name] [Preview][+] }| aa bb cc dd ee ff gg hh ii jj | aa^ | @@ -1379,49 +1238,24 @@ describe('builtin popupmenu', function() feed('iaa bb cc dd ee ff gg hh ii jj<cr>') feed('<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*9 {4:[No Name] [+] }| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| + [4:--------------------------------]|*8 {3:[No Name] [Preview][+] }| [3:--------------------------------]| ## grid 2 aa bb cc dd ee ff gg hh ii jj | aa^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 ## grid 3 {2:-- }{5:match 1 of 10} | ## grid 4 aa bb cc dd ee ff gg hh ii jj | aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 5 {s:aa }{c: }| {n:bb }{c: }| @@ -1431,9 +1265,11 @@ describe('builtin popupmenu', function() {n:ff }{c: }| {n:gg }{s: }| {n:hh }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 2, 2, 0, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 2, 2, 0, false, 100 }, + }, + } else screen:expect([[ aa bb cc dd ee ff gg hh ii jj | @@ -1448,12 +1284,7 @@ describe('builtin popupmenu', function() {n:hh }{s: }{4: }| aa bb cc dd ee ff gg hh ii jj | aa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {3:[No Name] [Preview][+] }| {2:-- }{5:match 1 of 10} | ]]) @@ -1467,26 +1298,12 @@ describe('builtin popupmenu', function() feed('kk<cr>ll<cr>mm<cr>nn<cr>oo<cr>') feed('<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| + [4:--------------------------------]|*4 {3:[No Name] [Preview][+] }| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*13 {4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 @@ -1524,9 +1341,11 @@ describe('builtin popupmenu', function() {n:kk }{c: }| {n:ll }{s: }| {n:mm }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "SW", 2, 12, 0, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'SW', 2, 12, 0, false, 100 }, + }, + } else screen:expect([[ aa | @@ -1559,26 +1378,12 @@ describe('builtin popupmenu', function() feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') feed('<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| + [4:--------------------------------]|*8 {3:[No Name] [Preview][+] }| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*9 {4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 @@ -1612,9 +1417,11 @@ describe('builtin popupmenu', function() {n:gg }{c: }| {n:hh }{c: }| {n:ii }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "SW", 2, 8, 0, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'SW', 2, 8, 0, false, 100 }, + }, + } else screen:expect([[ aa | @@ -1647,26 +1454,12 @@ describe('builtin popupmenu', function() feed('ff<cr>gg<cr>hh<cr>ii<cr>jj<cr>') feed('<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*9 {4:[No Name] [+] }| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| - [4:--------------------------------]| + [4:--------------------------------]|*8 {3:[No Name] [Preview][+] }| [3:--------------------------------]| ## grid 2 @@ -1699,9 +1492,11 @@ describe('builtin popupmenu', function() {n:ff }{c: }| {n:gg }{s: }| {n:hh }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "SW", 2, 8, 0, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'SW', 2, 8, 0, false, 100 }, + }, + } else screen:expect([[ {s:aa }{c: } | @@ -1747,43 +1542,19 @@ describe('builtin popupmenu', function() {n:one }{1: }| {n:two }{1: }| {n:three }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*15 {2:-- }{8:Back at original} | ]]) feed('<C-N>') screen:expect([[ 1info | - | - {1:~ }| + {1:~ }|*2 {3:[Scratch] [Preview] }| one^ | {s:one }{1: }| {n:two }{1: }| {n:three }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*10 {4:[No Name] [+] }| {2:-- }{5:match 1 of 3} | ]]) @@ -1814,46 +1585,203 @@ describe('builtin popupmenu', function() end) end + describe('floating window preview #popup', function() + it('pum popup preview', function() + --row must > 10 + screen:try_resize(30, 11) + exec([[ + funct Omni_test(findstart, base) + if a:findstart + return col(".") - 1 + endif + return [#{word: "one", info: "1info"}, #{word: "two", info: "2info"}, #{word: "three"}] + endfunc + set omnifunc=Omni_test + set completeopt=menu,popup + + funct Set_info() + let comp_info = complete_info() + if comp_info['selected'] == 2 + call nvim_complete_set(comp_info['selected'], {"info": "3info"}) + endif + endfunc + autocmd CompleteChanged * call Set_info() + ]]) + feed('Gi<C-x><C-o>') + + --floating preview in right + if multigrid then + screen:expect { + grid = [[ + ## grid 1 + [2:------------------------------]|*10 + [3:------------------------------]| + ## grid 2 + one^ | + {1:~ }|*9 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 4 + {n:1info}| + {n: }| + ## grid 5 + {s:one }| + {n:two }| + {n:three }| + ]], + float_pos = { + [5] = { -1, 'NW', 2, 1, 0, false, 100 }, + [4] = { 1001, 'NW', 1, 1, 15, true, 50 }, + }, + } + else + screen:expect { + grid = [[ + one^ | + {s:one }{n:1info}{1: }| + {n:two }{1: }| + {n:three }{1: }| + {1:~ }|*6 + {2:-- }{5:match 1 of 3} | + ]], + unchanged = true, + } + end + + -- test nvim_complete_set_info + feed('<C-N><C-N>') + vim.uv.sleep(10) + if multigrid then + screen:expect { + grid = [[ + ## grid 1 + [2:------------------------------]|*10 + [3:------------------------------]| + ## grid 2 + three^ | + {1:~ }|*9 + ## grid 3 + {2:-- }{5:match 3 of 3} | + ## grid 4 + {n:3info}| + {n: }| + ## grid 5 + {n:one }| + {n:two }| + {s:three }| + ]], + float_pos = { + [5] = { -1, 'NW', 2, 1, 0, false, 100 }, + [4] = { 1001, 'NW', 1, 1, 15, true, 50 }, + }, + } + else + screen:expect { + grid = [[ + three^ | + {n:one 3info}{1: }| + {n:two }{1: }| + {s:three }{1: }| + {1:~ }|*6 + {2:-- }{5:match 3 of 3} | + ]], + } + end + -- make sure info has set + feed('<C-y>') + eq('3info', exec_lua('return vim.v.completed_item.info')) + + -- preview in left + feed('<ESC>cc') + insert(('test'):rep(5)) + feed('i<C-x><C-o>') + if multigrid then + screen:expect { + grid = [[ + ## grid 1 + [2:------------------------------]|*10 + [3:------------------------------]| + ## grid 2 + itesttesttesttesttesone^t | + {1:~ }|*9 + ## grid 3 + {2:-- }{5:match 1 of 3} | + ## grid 5 + {s: one }| + {n: two }| + {n: three }| + ## grid 6 + {n:1info}| + {n: }| + ]], + float_pos = { + [5] = { -1, 'NW', 2, 1, 19, false, 100 }, + [6] = { 1002, 'NW', 1, 1, 1, true, 50 }, + }, + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 2, + curline = 0, + curcol = 23, + linecount = 1, + sum_scroll_delta = 0, + }, + [6] = { + win = 1002, + topline = 0, + botline = 2, + curline = 0, + curcol = 0, + linecount = 1, + sum_scroll_delta = 0, + }, + }, + } + else + screen:expect { + grid = [[ + itesttesttesttesttesone^t | + {1:~}{n:1info}{1: }{s: one }{1: }| + {1:~}{n: }{1: }{n: two }{1: }| + {1:~ }{n: three }{1: }| + {1:~ }|*6 + {2:-- }{5:match 1 of 3} | + ]], + } + end + end) + end) + it('with vsplits', function() screen:try_resize(32, 8) insert('aaa aab aac\n') feed(':vsplit<cr>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]|*6 {4:[No Name] [+] }{3:<Name] [+] }| [3:--------------------------------]| ## grid 2 aaa aab aac| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :vsplit | ## grid 4 aaa aab aac | ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - ]]} + {1:~ }|*4 + ]], + } else screen:expect([[ aaa aab aac │aaa aab aac| ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 {4:[No Name] [+] }{3:<Name] [+] }| :vsplit | ]]) @@ -1861,39 +1789,31 @@ describe('builtin popupmenu', function() feed('ibbb a<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| - [4:--------------------]│[2:-----------]| + [4:--------------------]│[2:-----------]|*6 {4:[No Name] [+] }{3:<Name] [+] }| [3:--------------------------------]| ## grid 2 aaa aab aac| bbb aaa | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 {2:-- }{5:match 1 of 3} | ## grid 4 aaa aab aac | bbb aaa^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 5 {s: aaa }| {n: aab }| {n: aac }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 2, 3, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 4, 2, 3, false, 100 }, + }, + } else screen:expect([[ aaa aab aac │aaa aab aac| @@ -1909,39 +1829,33 @@ describe('builtin popupmenu', function() feed('<esc><c-w><c-w>oc a<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]|*6 {3:<Name] [+] }{4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 aaa aab aac | bbb aaa | c aaa^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {2:-- }{5:match 1 of 3} | ## grid 4 aaa aab aac| bbb aaa | c aaa | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 5 {s: aaa }| {n: aab }| {n: aac }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 2, 3, 1, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 2, 3, 1, false, 100 }, + }, + } else screen:expect([[ aaa aab aac│aaa aab aac | @@ -1957,23 +1871,17 @@ describe('builtin popupmenu', function() feed('bcdef ccc a<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]|*6 {3:<Name] [+] }{4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 aaa aab aac | bbb aaa | c aaabcdef ccc aaa^ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 ## grid 3 {2:-- }{5:match 1 of 4} | ## grid 4 @@ -1981,16 +1889,17 @@ describe('builtin popupmenu', function() bbb aaa | c aaabcdef | ccc aaa | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 5 {s: aaa }| {n: aab }| {n: aac }| {n: aaabcdef}| - ]], float_pos={ - [5] = {{id = -1}, "NW", 2, 3, 11, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 2, 3, 11, false, 100 }, + }, + } else screen:expect([[ aaa aab aac│aaa aab aac | @@ -2006,14 +1915,10 @@ describe('builtin popupmenu', function() feed('\n<c-x><c-n>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| - [4:-----------]│[2:--------------------]| + [4:-----------]│[2:--------------------]|*6 {3:<Name] [+] }{4:[No Name] [+] }| [3:--------------------------------]| ## grid 2 @@ -2021,8 +1926,7 @@ describe('builtin popupmenu', function() bbb aaa | c aaabcdef ccc aaa | aaa^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 ## grid 3 {2:-- }{5:match 1 of 6} | ## grid 4 @@ -2036,9 +1940,11 @@ describe('builtin popupmenu', function() {s: aaa }{c: }| {n: aab }{s: }| {n: aac }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 2, 4, -1, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 2, 4, -1, false, 100 }, + }, + } else screen:expect([[ aaa aab aac│aaa aab aac | @@ -2055,10 +1961,10 @@ describe('builtin popupmenu', function() if not multigrid then it('with split and scroll', function() - screen:try_resize(60,14) - command("split") - command("set completeopt+=noinsert") - command("set mouse=a") + screen:try_resize(60, 14) + command('split') + command('set completeopt+=noinsert') + command('set mouse=a') insert([[ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor @@ -2108,7 +2014,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est ^ | L{n: sunt }{s: }sit amet, consectetur | @@ -2144,7 +2050,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'up', '', 0, 9, 40) + api.nvim_input_mouse('wheel', 'up', '', 0, 9, 40) screen:expect([[ Est e^ | L{n: elit } sit amet, consectetur | @@ -2180,7 +2086,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est es^ | L{n: esse } sit amet, consectetur | @@ -2234,7 +2140,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 9, 40) + api.nvim_input_mouse('wheel', 'down', '', 0, 9, 40) screen:expect([[ Est eu^ | L{n: elit } sit amet, consectetur | @@ -2252,7 +2158,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 22 of 65} | ]]) - funcs.complete(4, {'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) + fn.complete(4, { 'ea', 'eeeeeeeeeeeeeeeeee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }) screen:expect([[ Est eu^ | {s: ea }t amet, consectetur | @@ -2270,7 +2176,7 @@ describe('builtin popupmenu', function() {2:-- Keyword Local completion (^N^P) }{5:match 1 of 9} | ]]) - funcs.complete(4, {'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö'}) + fn.complete(4, { 'ea', 'eee', 'ei', 'eo', 'eu', 'ey', 'eå', 'eä', 'eö' }) screen:expect([[ Est eu^ | {s: ea }r sit amet, consectetur | @@ -2306,7 +2212,7 @@ describe('builtin popupmenu', function() {2:-- INSERT --} | ]]) - funcs.complete(6, {'foo', 'bar'}) + fn.complete(6, { 'foo', 'bar' }) screen:expect([[ Esteee^ | Lo{s: foo }sit amet, consectetur | @@ -2345,29 +2251,16 @@ describe('builtin popupmenu', function() it('can be moved due to wrap or resize', function() feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + command('set completeopt+=noinsert,noselect') + command('set linebreak') + fn.complete(29, { 'word', 'choice', 'text', 'thing' }) screen:expect([[ some long prefix before the ^ | {1:~ }{n: word }| {1:~ }{n: choice}| {1:~ }{n: text }| {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*14 {2:-- INSERT --} | ]]) @@ -2379,19 +2272,7 @@ describe('builtin popupmenu', function() {n:choice }{1: }| {n:text }{1: }| {s:thing }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*13 {2:-- INSERT --} | ]]) @@ -2402,24 +2283,11 @@ describe('builtin popupmenu', function() {1:~ }{n: choice}| {1:~ }{s: text }| {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*14 {2:-- INSERT --} | ]]) - screen:try_resize(30,8) + screen:try_resize(30, 8) screen:expect([[ some long prefix before the | text^ | @@ -2431,19 +2299,18 @@ describe('builtin popupmenu', function() {2:-- INSERT --} | ]]) - screen:try_resize(50,8) + screen:try_resize(50, 8) screen:expect([[ some long prefix before the text^ | {1:~ }{n: word }{1: }| {1:~ }{n: choice }{1: }| {1:~ }{s: text }{1: }| {1:~ }{n: thing }{1: }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) - screen:try_resize(25,10) + screen:try_resize(25, 10) screen:expect([[ some long prefix before | the text^ | @@ -2451,13 +2318,11 @@ describe('builtin popupmenu', function() {1:~ }{n: choice }{1: }| {1:~ }{s: text }{1: }| {1:~ }{n: thing }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]) - screen:try_resize(12,5) + screen:try_resize(12, 5) screen:expect([[ some long | prefix | @@ -2467,14 +2332,14 @@ describe('builtin popupmenu', function() ]]) -- can't draw the pum, but check we don't crash - screen:try_resize(12,2) + screen:try_resize(12, 2) screen:expect([[ {1:<<<}t^ | {2:-- INSERT --}| ]]) -- but state is preserved, pum reappears - screen:try_resize(20,8) + screen:try_resize(20, 8) screen:expect([[ some long prefix | before the text^ | @@ -2489,34 +2354,21 @@ describe('builtin popupmenu', function() it('with VimResized autocmd', function() feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("autocmd VimResized * redraw!") - command("set linebreak") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + command('set completeopt+=noinsert,noselect') + command('autocmd VimResized * redraw!') + command('set linebreak') + fn.complete(29, { 'word', 'choice', 'text', 'thing' }) screen:expect([[ some long prefix before the ^ | {1:~ }{n: word }| {1:~ }{n: choice}| {1:~ }{n: text }| {1:~ }{n: thing }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*14 {2:-- INSERT --} | ]]) - screen:try_resize(16,10) + screen:try_resize(16, 10) screen:expect([[ some long | prefix before | @@ -2525,60 +2377,29 @@ describe('builtin popupmenu', function() {1:~ }{n: choice }| {1:~ }{n: text }| {1:~ }{n: thing }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) end) it('with rightleft window', function() - command("set rl wildoptions+=pum") + command('set rl wildoptions+=pum') feed('isome rightleft ') screen:expect([[ ^ tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*18 {2:-- INSERT --} | ]]) - command("set completeopt+=noinsert,noselect") - funcs.complete(16, {'word', 'choice', 'text', 'thing'}) + command('set completeopt+=noinsert,noselect') + fn.complete(16, { 'word', 'choice', 'text', 'thing' }) screen:expect([[ ^ tfelthgir emos| {1: }{n: drow }{1: ~}| {1: }{n: eciohc }{1: ~}| {1: }{n: txet }{1: ~}| {1: }{n: gniht }{1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*14 {2:-- INSERT --} | ]]) @@ -2589,87 +2410,32 @@ describe('builtin popupmenu', function() {1: }{n: eciohc }{1: ~}| {1: }{n: txet }{1: ~}| {1: }{n: gniht }{1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*14 {2:-- INSERT --} | ]]) feed('<c-y>') screen:expect([[ ^ drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*18 {2:-- INSERT --} | ]]) -- not rightleft on the cmdline feed('<esc>:sign ') - screen:expect{grid=[[ + screen:expect { + grid = [[ drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*18 :sign ^ | - ]]} + ]], + } feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ drow tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*12 {1: }{s: define }{1: ~}| {1: }{n: jump }{1: ~}| {1: }{n: list }{1: ~}| @@ -2677,7 +2443,8 @@ describe('builtin popupmenu', function() {1: }{n: undefine }{1: ~}| {1: }{n: unplace }{1: ~}| :sign define^ | - ]]} + ]], + } end) end @@ -2688,34 +2455,30 @@ describe('builtin popupmenu', function() command('set completeopt+=noinsert,noselect') command('set pumheight=2') feed('isome rightleft ') - funcs.complete(16, {'word', 'choice', 'text', 'thing'}) + fn.complete(16, { 'word', 'choice', 'text', 'thing' }) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]|*4 {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ## grid 3 {2:-- INSERT --} | ## grid 4 ^ tfelthgir emos| - {1: ~}| - {1: ~}| - {1: ~}| + {1: ~}|*3 ## grid 5 {c: }{n: drow }| {s: }{n: eciohc }| - ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 1, -11, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 4, 1, -11, false, 100 }, + }, + } else screen:expect([[ tfelthgir emos│ ^ tfelthgir emos| @@ -2727,34 +2490,32 @@ describe('builtin popupmenu', function() ]]) end feed('<C-E><CR>') - funcs.complete(1, {'word', 'choice', 'text', 'thing'}) + fn.complete(1, { 'word', 'choice', 'text', 'thing' }) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]|*4 {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 tfelthgir emos| | - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 3 {2:-- INSERT --} | ## grid 4 tfelthgir emos| ^ | - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 5 {c: }{n: drow}| {s: }{n: eciohc}| - ]], float_pos={ - [5] = {{id = -1}, "NW", 4, 2, 4, false, 100}; - }} + ]], + float_pos = { + [5] = { -1, 'NW', 4, 2, 4, false, 100 }, + }, + } else screen:expect([[ tfelthgir emos│ tfelthgir emos| @@ -2766,35 +2527,31 @@ describe('builtin popupmenu', function() ]]) end feed('<C-E>') - async_meths.call_function('input', {'', '', 'sign'}) + async_meths.nvim_call_function('input', { '', '', 'sign' }) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]|*4 {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 tfelthgir emos| | - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 3 ^ | ## grid 4 tfelthgir emos| | - {1: ~}| - {1: ~}| - ]]} + {1: ~}|*2 + ]], + } else screen:expect([[ tfelthgir emos│ tfelthgir emos| │ | - {1: ~}│{1: ~}| - {1: ~}│{1: ~}| + {1: ~}│{1: ~}|*2 {3:[No Name] [+] }{4:[No Name] [+] }| ^ | ]]) @@ -2802,32 +2559,30 @@ describe('builtin popupmenu', function() command('set wildoptions+=pum') feed('<Tab>') if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| - [2:-------------------]│[4:--------------------]| + [2:-------------------]│[4:--------------------]|*4 {3:[No Name] [+] }{4:[No Name] [+] }| [3:----------------------------------------]| ## grid 2 tfelthgir emos| | - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 3 define^ | ## grid 4 tfelthgir emos| | - {1: ~}| - {1: ~}| + {1: ~}|*2 ## grid 5 {s:define }{c: }| {n:jump }{s: }| - ]], float_pos={ - [5] = {{id = -1}, "SW", 1, 5, 0, false, 250}; - }} + ]], + float_pos = { + [5] = { -1, 'SW', 1, 5, 0, false, 250 }, + }, + } else screen:expect([[ tfelthgir emos│ tfelthgir emos| @@ -2842,10 +2597,10 @@ describe('builtin popupmenu', function() if not multigrid then it('with multiline messages', function() - screen:try_resize(40,8) + screen:try_resize(40, 8) feed('ixx<cr>') command('imap <f2> <cmd>echoerr "very"\\|echoerr "much"\\|echoerr "error"<cr>') - funcs.complete(1, {'word', 'choice', 'text', 'thing'}) + fn.complete(1, { 'word', 'choice', 'text', 'thing' }) screen:expect([[ xx | word^ | @@ -2893,7 +2648,7 @@ describe('builtin popupmenu', function() {2:-- INSERT --} | ]]) - command("split") + command('split') screen:expect([[ xx | choice^ | @@ -2905,8 +2660,9 @@ describe('builtin popupmenu', function() {2:-- INSERT --} | ]]) - meths.input_mouse('wheel', 'down', '', 0, 6, 15) - screen:expect{grid=[[ + api.nvim_input_mouse('wheel', 'down', '', 0, 6, 15) + screen:expect { + grid = [[ xx | choice^ | {n:word }{1: }| @@ -2915,21 +2671,25 @@ describe('builtin popupmenu', function() {n:thing }{1: }| {3:[No Name] [+] }| {2:-- INSERT --} | - ]], unchanged=true} + ]], + unchanged = true, + } end) it('with kind, menu and abbr attributes', function() - screen:try_resize(40,8) + screen:try_resize(40, 8) feed('ixx ') - funcs.complete(4, {{word='wordey', kind= 'x', menu='extrainfo'}, 'thing', {word='secret', abbr='sneaky', menu='bar'}}) + fn.complete(4, { + { word = 'wordey', kind = 'x', menu = 'extrainfo' }, + 'thing', + { word = 'secret', abbr = 'sneaky', menu = 'bar' }, + }) screen:expect([[ xx wordey^ | {1:~ }{s: wordey x extrainfo }{1: }| {1:~ }{n: thing }{1: }| {1:~ }{n: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]) @@ -2939,9 +2699,7 @@ describe('builtin popupmenu', function() {1:~ }{n: wordey x extrainfo }{1: }| {1:~ }{n: thing }{1: }| {1:~ }{n: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]) @@ -2951,51 +2709,36 @@ describe('builtin popupmenu', function() {1:~ }{n: wordey x extrainfo }{1: }| {1:~ }{n: thing }{1: }| {1:~ }{s: sneaky bar }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- INSERT --} | ]]) feed('<esc>') screen:expect([[ xx secre^t | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 | ]]) end) it('wildoptions=pum', function() - screen:try_resize(32,10) + screen:try_resize(32, 10) command('set wildmenu') command('set wildoptions=pum') command('set shellslash') - command("cd test/functional/fixtures/wildpum") + command('cd test/functional/fixtures/wildpum') feed(':sign ') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign ^ | ]]) feed('<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3008,8 +2751,7 @@ describe('builtin popupmenu', function() feed('<Right><Right>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{s: list }{1: }| @@ -3022,8 +2764,7 @@ describe('builtin popupmenu', function() feed('<C-N>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3036,8 +2777,7 @@ describe('builtin popupmenu', function() feed('<C-P>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{s: list }{1: }| @@ -3050,8 +2790,7 @@ describe('builtin popupmenu', function() feed('<Left>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{s: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3065,14 +2804,7 @@ describe('builtin popupmenu', function() feed('<C-E>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign ^ | ]]) @@ -3080,14 +2812,7 @@ describe('builtin popupmenu', function() feed('<Tab><C-P><C-P><C-Y>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign unplace^ | ]]) @@ -3095,8 +2820,7 @@ describe('builtin popupmenu', function() feed('<C-U>sign define <Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: culhl= }{1: }| {1:~ }{n: icon= }{1: }| {1:~ }{n: linehl= }{1: }| @@ -3109,8 +2833,7 @@ describe('builtin popupmenu', function() feed('<Space><Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: culhl= }{1: }| {1:~ }{n: icon= }{1: }| {1:~ }{n: linehl= }{1: }| @@ -3123,12 +2846,7 @@ describe('builtin popupmenu', function() feed('<C-U>e Xnamedi<Tab><Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {1:~ }{s: XdirA/ }{1: }| {1:~ }{n: XfileA }{1: }| :e Xnamedir/XdirA/^ | @@ -3138,12 +2856,7 @@ describe('builtin popupmenu', function() feed('<Down>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {1:~ }{s: XdirB/ }{1: }| {1:~ }{n: XfileB }{1: }| :e Xnamedir/XdirA/XdirB/^ | @@ -3153,12 +2866,7 @@ describe('builtin popupmenu', function() feed('<Up>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {1:~ }{s: XdirA/ }{1: }| {1:~ }{n: XfileA }{1: }| :e Xnamedir/XdirA/^ | @@ -3169,12 +2877,7 @@ describe('builtin popupmenu', function() feed(':<C-U>sign <Tab><C-A>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {4: }| :sign define jump list place und| efine unplace^ | @@ -3184,12 +2887,7 @@ describe('builtin popupmenu', function() feed('<Left>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {4: }| :sign define jump list place und| efine unplac^e | @@ -3201,11 +2899,7 @@ describe('builtin popupmenu', function() feed('<C-U>sign <Tab><C-D>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {4: }| :sign define | define | @@ -3216,8 +2910,7 @@ describe('builtin popupmenu', function() feed('<C-U><CR>:sign <S-Tab><C-P>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3231,14 +2924,7 @@ describe('builtin popupmenu', function() feed('<C-U><CR>:sign <Tab><Esc>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | ]]) @@ -3246,14 +2932,7 @@ describe('builtin popupmenu', function() feed(':sign <Tab>x') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign definex^ | ]]) @@ -3264,10 +2943,7 @@ describe('builtin popupmenu', function() {3:[No Name] }| {1::}sign define | {1::}sign defin^e | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {4:[Command Line] }| :sign define | ]]) @@ -3277,12 +2953,7 @@ describe('builtin popupmenu', function() feed(':sign u<Tab><C-N><C-N>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {1:~ }{n: undefine }{1: }| {1:~ }{n: unplace }{1: }| :sign u^ | @@ -3292,10 +2963,7 @@ describe('builtin popupmenu', function() feed('<C-U>bu<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {s: bufdo }{1: }| {n: buffer }{1: }| {n: buffers }{1: }| @@ -3307,14 +2975,7 @@ describe('builtin popupmenu', function() feed('<C-E><C-U>sign <Tab><BS>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign defin^ | ]]) @@ -3322,14 +2983,7 @@ describe('builtin popupmenu', function() feed('<C-E><C-U>sign <Tab><C-W>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign ^ | ]]) @@ -3337,14 +2991,7 @@ describe('builtin popupmenu', function() feed('<C-E><C-U>sign <Tab><C-U>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :^ | ]]) @@ -3353,14 +3000,7 @@ describe('builtin popupmenu', function() feed('sign xyz<Esc>:sign <Tab><C-E><Up>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :sign xyz^ | ]]) @@ -3371,9 +3011,7 @@ describe('builtin popupmenu', function() feed(':cn<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4: }| :cn | cnewer cnoreabbrev | @@ -3384,9 +3022,7 @@ describe('builtin popupmenu', function() feed('s') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4: }| :cn | cnewer cnoreabbrev | @@ -3402,11 +3038,7 @@ describe('builtin popupmenu', function() feed(':e あいう/<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {1:~ }{s: 123 }{1: }| {1:~ }{n: abc }{1: }| {1:~ }{n: xyz }{1: }| @@ -3418,8 +3050,7 @@ describe('builtin popupmenu', function() feed(':sign <Tab><PageDown>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3431,8 +3062,7 @@ describe('builtin popupmenu', function() feed('<PageDown>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3444,8 +3074,7 @@ describe('builtin popupmenu', function() feed('<PageDown>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3457,8 +3086,7 @@ describe('builtin popupmenu', function() feed('<PageDown>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3470,8 +3098,7 @@ describe('builtin popupmenu', function() feed('<C-U>sign <Tab><Right><Right><PageDown>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3485,8 +3112,7 @@ describe('builtin popupmenu', function() feed('<C-U>sign <Tab><PageUp>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3498,8 +3124,7 @@ describe('builtin popupmenu', function() feed('<PageUp>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3511,8 +3136,7 @@ describe('builtin popupmenu', function() feed('<PageUp>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{s: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3524,8 +3148,7 @@ describe('builtin popupmenu', function() feed('<PageUp>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3539,12 +3162,7 @@ describe('builtin popupmenu', function() feed('<Esc>:set wildchazz<Left><Left><Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 {1:~ }{s: wildchar }{1: }| {1:~ }{n: wildcharm }{1: }| :set wildchar^zz | @@ -3552,14 +3170,7 @@ describe('builtin popupmenu', function() feed('<C-E>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :set wildcha^zz | ]]) @@ -3567,28 +3178,19 @@ describe('builtin popupmenu', function() feed('<Esc>:set wildchazz<Left><Left><Tab><C-Y>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 :set wildchar^zz | ]]) feed('<Esc>') -- check positioning with multibyte char in pattern - command("e långfile1") - command("sp långfile2") + command('e långfile1') + command('sp långfile2') feed(':b lå<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {4:långfile2 }| | {1:~ }| @@ -3598,7 +3200,7 @@ describe('builtin popupmenu', function() ]]) -- check doesn't crash on screen resize - screen:try_resize(20,6) + screen:try_resize(20, 6) screen:expect([[ | {1:~ }| @@ -3608,20 +3210,13 @@ describe('builtin popupmenu', function() :b långfile1^ | ]]) - screen:try_resize(50,15) + screen:try_resize(50, 15) screen:expect([[ | {1:~ }| {4:långfile2 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 {1:~ }{s: långfile1 }{1: }| {3:lå}{n: långfile2 }{3: }| :b långfile1^ | @@ -3636,21 +3231,14 @@ describe('builtin popupmenu', function() {1:~ }| {4:långfile2 }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 {1:~ }{n: långfile1 }{1: }| {3:lå}{n: långfile2 }{3: }| :b långfile^ | ]]) feed('<esc>') - command("close") + command('close') command('set wildmode=full') -- special case: when patterns ends with "/", show menu items aligned @@ -3658,17 +3246,7 @@ describe('builtin popupmenu', function() feed(':e compdir/<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 {1:~ }{s: file1 }{1: }| {1:~ }{n: file2 }{1: }| :e compdir/file1^ | @@ -3676,29 +3254,27 @@ describe('builtin popupmenu', function() end) it('wildoptions=pum with scrolled messages', function() - screen:try_resize(40,10) + screen:try_resize(40, 10) command('set wildmenu') command('set wildoptions=pum') feed(':echoerr "fail"|echoerr "error"<cr>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {4: }| {6:fail} | {6:error} | {5:Press ENTER or type command to continue}^ | - ]]} + ]], + } feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3706,25 +3282,24 @@ describe('builtin popupmenu', function() {6:fail} {n: undefine } | {6:error}{n: unplace } | :sign define^ | - ]]} + ]], + } feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {4: }| {6:fail} | {6:error} | :sign defined^ | - ]]} + ]], + } end) it('wildoptions=pum and wildmode=longest,full #11622', function() - screen:try_resize(30,8) + screen:try_resize(30, 8) command('set wildmenu') command('set wildoptions=pum') command('set wildmode=longest,full') @@ -3732,56 +3307,49 @@ describe('builtin popupmenu', function() -- With 'wildmode' set to 'longest,full', completing a match should display -- the longest match, the wildmenu should not be displayed. feed(':sign u<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 :sign un^ | - ]]} - eq(0, funcs.wildmenumode()) + ]], + } + eq(0, fn.wildmenumode()) -- pressing <Tab> should display the wildmenu feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {1:~ }{s: undefine }{1: }| {1:~ }{n: unplace }{1: }| :sign undefine^ | - ]]} - eq(1, funcs.wildmenumode()) + ]], + } + eq(1, fn.wildmenumode()) -- pressing <Tab> second time should select the next entry in the menu feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {1:~ }{n: undefine }{1: }| {1:~ }{s: unplace }{1: }| :sign unplace^ | - ]]} + ]], + } end) it('wildoptions=pum with a wrapped line in buffer vim-patch:8.2.4655', function() screen:try_resize(32, 10) - meths.buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) + api.nvim_buf_set_lines(0, 0, -1, true, { ('a'):rep(100) }) command('set wildoptions+=pum') feed('$') feed(':sign <Tab>') screen:expect([[ - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|*3 aaaa {s: define } | {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3805,8 +3373,7 @@ describe('builtin popupmenu', function() feed(':sign <C-E>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3820,8 +3387,7 @@ describe('builtin popupmenu', function() feed('<C-E>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: define }{1: }| {1:~ }{s: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3834,14 +3400,7 @@ describe('builtin popupmenu', function() feed('<Esc>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | ]]) @@ -3851,8 +3410,7 @@ describe('builtin popupmenu', function() feed(':sign <Esc>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3865,14 +3423,7 @@ describe('builtin popupmenu', function() feed('<Esc>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | ]]) @@ -3882,8 +3433,7 @@ describe('builtin popupmenu', function() feed([[:sign <C-\><C-\>]]) screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{s: define }{1: }| {1:~ }{n: jump }{1: }| {1:~ }{n: list }{1: }| @@ -3896,93 +3446,65 @@ describe('builtin popupmenu', function() feed('<C-N>') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*8 | ]]) end) end it("'pumheight'", function() - screen:try_resize(32,8) + screen:try_resize(32, 8) feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - command("set pumheight=2") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + command('set completeopt+=noinsert,noselect') + command('set linebreak') + command('set pumheight=2') + fn.complete(29, { 'word', 'choice', 'text', 'thing' }) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*7 [3:--------------------------------]| ## grid 2 some long prefix before the ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 {2:-- INSERT --} | ## grid 4 {n: word }{c: }| {n: choice}{s: }| - ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 1, 24, false, 100}; - }} + ]], + float_pos = { + [4] = { -1, 'NW', 2, 1, 24, false, 100 }, + }, + } else screen:expect([[ some long prefix before the ^ | {1:~ }{n: word }{c: }| {1:~ }{n: choice}{s: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {2:-- INSERT --} | ]]) end end) it("'pumwidth'", function() - screen:try_resize(32,8) + screen:try_resize(32, 8) feed('isome long prefix before the ') - command("set completeopt+=noinsert,noselect") - command("set linebreak") - command("set pumwidth=8") - funcs.complete(29, {'word', 'choice', 'text', 'thing'}) + command('set completeopt+=noinsert,noselect') + command('set linebreak') + command('set pumwidth=8') + fn.complete(29, { 'word', 'choice', 'text', 'thing' }) if multigrid then - screen:expect{grid=[[ + screen:expect { + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*7 [3:--------------------------------]| ## grid 2 some long prefix before the ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 {2:-- INSERT --} | ## grid 4 @@ -3990,9 +3512,11 @@ describe('builtin popupmenu', function() {n: choice}| {n: text }| {n: thing }| - ]], float_pos={ - [4] = {{id = -1}, "NW", 2, 1, 25, false, 100}; - }} + ]], + float_pos = { + [4] = { -1, 'NW', 2, 1, 25, false, 100 }, + }, + } else screen:expect([[ some long prefix before the ^ | @@ -4000,8 +3524,7 @@ describe('builtin popupmenu', function() {1:~ }{n: choice}| {1:~ }{n: text }| {1:~ }{n: thing }| - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:-- INSERT --} | ]]) end @@ -4009,16 +3532,16 @@ describe('builtin popupmenu', function() it('does not crash when displayed in the last column with rightleft #12032', function() local col = 30 - local items = {'word', 'choice', 'text', 'thing'} + local items = { 'word', 'choice', 'text', 'thing' } local max_len = 0 for _, v in ipairs(items) do max_len = max_len < #v and #v or max_len end screen:try_resize(col, 8) command('set rightleft') - command('call setline(1, repeat(" ", &columns - '..max_len..'))') + command('call setline(1, repeat(" ", &columns - ' .. max_len .. '))') feed('$i') - funcs.complete(col - max_len, items) + fn.complete(col - max_len, items) feed('<c-y>') assert_alive() end) @@ -4027,91 +3550,66 @@ describe('builtin popupmenu', function() screen:try_resize(32, 8) command('set completeopt+=menuone,noselect') feed('i' .. string.rep(' ', 13)) - funcs.complete(14, {'哦哦哦哦哦哦哦哦哦哦'}) + fn.complete(14, { '哦哦哦哦哦哦哦哦哦哦' }) if multigrid then - screen:expect({grid=[[ + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*7 [3:--------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 {2:-- INSERT --} | ## grid 4 {n: 哦哦哦哦哦哦哦哦哦>}| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 12, false, 100}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 12, false, 100 } }, + }) else screen:expect([[ ^ | {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {2:-- INSERT --} | ]]) end end) it('truncates double-width character correctly with scrollbar', function() - screen:try_resize(32,8) + screen:try_resize(32, 8) command('set completeopt+=noselect') command('set pumheight=4') feed('i' .. string.rep(' ', 12)) local items = {} for _ = 1, 8 do - table.insert(items, {word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1}) + table.insert(items, { word = '哦哦哦哦哦哦哦哦哦哦', equal = 1, dup = 1 }) end - funcs.complete(13, items) + fn.complete(13, items) if multigrid then - screen:expect({grid=[[ + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*7 [3:--------------------------------]| ## grid 2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 ## grid 3 {2:-- INSERT --} | ## grid 4 - {n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {n: 哦哦哦哦哦哦哦哦哦>}{s: }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 11, false, 100}}}) + {n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2 + {n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2 + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 11, false, 100 } }, + }) else screen:expect([[ ^ | - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }| - {1:~ }| - {1:~ }| + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{c: }|*2 + {1:~ }{n: 哦哦哦哦哦哦哦哦哦>}{s: }|*2 + {1:~ }|*2 {2:-- INSERT --} | ]]) end @@ -4130,28 +3628,24 @@ describe('builtin popupmenu', function() ]]) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else feed('<RightMouse><4,0>') screen:expect([[ @@ -4165,27 +3659,23 @@ describe('builtin popupmenu', function() end feed('<Down>') if multigrid then - screen:expect({grid=[[ + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 {s: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else screen:expect([[ ^popup menu test | @@ -4198,27 +3688,23 @@ describe('builtin popupmenu', function() end feed('<Down>') if multigrid then - screen:expect({grid=[[ + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 | ## grid 4 {n: foo }| {s: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else screen:expect([[ ^popup menu test | @@ -4231,124 +3717,158 @@ describe('builtin popupmenu', function() end feed('<CR>') if multigrid then - screen:expect({grid=[[ + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'bar' | - ]]}) + ]], + }) else screen:expect([[ ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :let g:menustr = 'bar' | ]]) end - eq('bar', meths.get_var('menustr')) + eq('bar', api.nvim_get_var('menustr')) if multigrid then - meths.input_mouse('right', 'press', '', 2, 2, 20) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 2, 2, 20) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'bar' | ## grid 4 {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 3, 19, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } }, + }) else feed('<RightMouse><20,2>') screen:expect([[ ^popup menu test | - {1:~ }| - {1:~ }| + {1:~ }|*2 {1:~ }{n: foo }{1: }| {1:~ }{n: bar }{1: }| :let g:menustr = 'b{n: baz } | ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 2, 0, 18) + screen:expect { + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | + {1:~ }|*4 + ## grid 3 + :let g:menustr = 'bar' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 17, false, 250 } }, + } + else + feed('<RightMouse><18,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + :let g:menustr = 'bar' | + ]]) + end + if multigrid then + api.nvim_input_mouse('right', 'press', '', 4, 1, 3) + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*5 + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }|*4 + ## grid 3 + :let g:menustr = 'bar' | + ## grid 4 + {n: foo }| + {n: bar }| + {n: baz }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 3, 19, false, 250 } }, + }) + else + feed('<RightMouse><20,2>') + screen:expect([[ + ^popup menu test | + {1:~ }|*2 + {1:~ }{n: foo }{1: }| + {1:~ }{n: bar }{1: }| + :let g:menustr = 'b{n: baz } | + ]]) + end + if multigrid then + api.nvim_input_mouse('left', 'press', '', 4, 2, 2) + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*5 + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }|*4 ## grid 3 :let g:menustr = 'baz' | - ]]}) + ]], + }) else - feed('<LeftMouse><22,5>') + feed('<LeftMouse><21,5>') screen:expect([[ ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :let g:menustr = 'baz' | ]]) end - eq('baz', meths.get_var('menustr')) + eq('baz', api.nvim_get_var('menustr')) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'baz' | ## grid 4 {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else feed('<RightMouse><4,0>') screen:expect([[ @@ -4361,28 +3881,24 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'drag', '', 2, 3, 6) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'drag', '', 2, 3, 6) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'baz' | ## grid 4 {n: foo }| {n: bar }| {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else feed('<RightDrag><6,3>') screen:expect([[ @@ -4395,61 +3911,49 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('right', 'release', '', 2, 1, 6) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'release', '', 2, 1, 6) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'foo' | - ]]}) + ]], + }) else feed('<RightRelease><6,1>') screen:expect([[ ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :let g:menustr = 'foo' | ]]) end - eq('foo', meths.get_var('menustr')) + eq('foo', api.nvim_get_var('menustr')) eq(false, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('right', 'press', '', 2, 0, 4) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 2, 0, 4) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 ## grid 3 :let g:menustr = 'foo' | ## grid 4 {n: foo }| {n: bar }| {n: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else feed('<RightMouse><4,0>') screen:expect([[ @@ -4463,28 +3967,55 @@ describe('builtin popupmenu', function() end eq(true, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('move', '', '', 2, 3, 6) - screen:expect({grid=[[ + api.nvim_input_mouse('wheel', 'up', '', 2, 0, 4) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | + {1:~ }|*4 + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {s: foo }| + {n: bar }| + {n: baz }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) + else + feed('<ScrollWheelUp><4,0>') + screen:expect([[ + ^popup menu test | + {1:~ }{s: foo }{1: }| + {1:~ }{n: bar }{1: }| + {1:~ }{n: baz }{1: }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq(true, screen.options.mousemoveevent) + if multigrid then + api.nvim_input_mouse('move', '', '', 4, 2, 3) + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*5 + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }|*4 ## grid 3 :let g:menustr = 'foo' | ## grid 4 {n: foo }| {n: bar }| {s: baz }| - ]], float_pos={[4] = {{id = -1}, 'NW', 2, 1, 3, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) else feed('<MouseMove><6,3>') screen:expect([[ @@ -4498,48 +4029,70 @@ describe('builtin popupmenu', function() end eq(true, screen.options.mousemoveevent) if multigrid then - meths.input_mouse('left', 'press', '', 2, 2, 6) - screen:expect({grid=[[ + api.nvim_input_mouse('wheel', 'down', '', 4, 2, 3) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*5 [3:--------------------------------]| ## grid 2 ^popup menu test | + {1:~ }|*4 + ## grid 3 + :let g:menustr = 'foo' | + ## grid 4 + {n: foo }| + {s: bar }| + {n: baz }| + ]], + float_pos = { [4] = { -1, 'NW', 2, 1, 3, false, 250 } }, + }) + else + feed('<ScrollWheelDown><6,3>') + screen:expect([[ + ^popup menu test | + {1:~ }{n: foo }{1: }| + {1:~ }{s: bar }{1: }| + {1:~ }{n: baz }{1: }| {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + :let g:menustr = 'foo' | + ]]) + end + eq(true, screen.options.mousemoveevent) + if multigrid then + api.nvim_input_mouse('left', 'press', '', 4, 1, 3) + screen:expect({ + grid = [[ + ## grid 1 + [2:--------------------------------]|*5 + [3:--------------------------------]| + ## grid 2 + ^popup menu test | + {1:~ }|*4 ## grid 3 :let g:menustr = 'bar' | - ]]}) + ]], + }) else feed('<LeftMouse><6,2>') screen:expect([[ ^popup menu test | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :let g:menustr = 'bar' | ]]) end eq(false, screen.options.mousemoveevent) - eq('bar', meths.get_var('menustr')) + eq('bar', api.nvim_get_var('menustr')) command('set laststatus=0 | botright split') if multigrid then - meths.input_mouse('right', 'press', '', 5, 1, 20) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 5, 1, 20) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:--------------------------------]| - [5:--------------------------------]| + [5:--------------------------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4553,7 +4106,9 @@ describe('builtin popupmenu', function() ## grid 5 ^popup menu test | {1:~ }| - ]], float_pos={[4] = {{id = -1}, "SW", 5, 1, 19, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'SW', 5, 1, 19, false, 250 } }, + }) else feed('<RightMouse><20,4>') screen:expect([[ @@ -4566,14 +4121,13 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 2, 2) - screen:expect({grid=[[ + api.nvim_input_mouse('left', 'press', '', 4, 2, 2) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:--------------------------------]| - [5:--------------------------------]| + [5:--------------------------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4583,9 +4137,10 @@ describe('builtin popupmenu', function() ## grid 5 ^popup menu test | {1:~ }| - ]]}) + ]], + }) else - feed('<LeftMouse><22,3>') + feed('<LeftMouse><21,3>') screen:expect([[ popup menu test | {1:~ }| @@ -4595,18 +4150,17 @@ describe('builtin popupmenu', function() :let g:menustr = 'baz' | ]]) end - eq('baz', meths.get_var('menustr')) + eq('baz', api.nvim_get_var('menustr')) command('set winwidth=1 | rightbelow vsplit') if multigrid then - meths.input_mouse('right', 'press', '', 6, 1, 14) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 6, 1, 14) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:---------------]│[6:----------------]| - [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4623,7 +4177,9 @@ describe('builtin popupmenu', function() ## grid 6 ^popup menu test | {1:~ }| - ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } }, + }) else feed('<RightMouse><30,4>') screen:expect([[ @@ -4636,14 +4192,13 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 0, 2) - screen:expect({grid=[[ + api.nvim_input_mouse('left', 'press', '', 4, 0, 2) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:---------------]│[6:----------------]| - [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4656,7 +4211,8 @@ describe('builtin popupmenu', function() ## grid 6 ^popup menu test | {1:~ }| - ]]}) + ]], + }) else feed('<LeftMouse><31,1>') screen:expect([[ @@ -4668,18 +4224,17 @@ describe('builtin popupmenu', function() :let g:menustr = 'foo' | ]]) end - eq('foo', meths.get_var('menustr')) + eq('foo', api.nvim_get_var('menustr')) command('setlocal winbar=WINBAR') if multigrid then - meths.input_mouse('right', 'press', '', 6, 1, 14) - screen:expect({grid=[[ + api.nvim_input_mouse('right', 'press', '', 6, 1, 14) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:---------------]│[6:----------------]| - [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4696,7 +4251,9 @@ describe('builtin popupmenu', function() ## grid 6 {2:WINBAR }| ^popup menu test | - ]], float_pos={[4] = {{id = -1}, "SW", 6, 1, 12, false, 250}}}) + ]], + float_pos = { [4] = { -1, 'SW', 6, 1, 12, false, 250 } }, + }) else feed('<RightMouse><30,4>') screen:expect([[ @@ -4709,14 +4266,13 @@ describe('builtin popupmenu', function() ]]) end if multigrid then - meths.input_mouse('left', 'press', '', 4, 1, 2) - screen:expect({grid=[[ + api.nvim_input_mouse('left', 'press', '', 4, 1, 2) + screen:expect({ + grid = [[ ## grid 1 - [2:--------------------------------]| - [2:--------------------------------]| + [2:--------------------------------]|*2 {3:[No Name] [+] }| - [5:---------------]│[6:----------------]| - [5:---------------]│[6:----------------]| + [5:---------------]│[6:----------------]|*2 [3:--------------------------------]| ## grid 2 popup menu test | @@ -4729,7 +4285,8 @@ describe('builtin popupmenu', function() ## grid 6 {2:WINBAR }| ^popup menu test | - ]]}) + ]], + }) else feed('<LeftMouse><31,2>') screen:expect([[ @@ -4741,7 +4298,7 @@ describe('builtin popupmenu', function() :let g:menustr = 'bar' | ]]) end - eq('bar', meths.get_var('menustr')) + eq('bar', api.nvim_get_var('menustr')) end) if not multigrid then @@ -4779,13 +4336,7 @@ describe('builtin popupmenu', function() {1:~ }{n: Select Line }{1: }| {1:~ }{n: Select Block }{1: }| {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 :popup PopUp | ]]) @@ -4804,13 +4355,7 @@ describe('builtin popupmenu', function() {1:~ }{n: Select Line }{1: }| {1:~ }{n: Select Block }{1: }| {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 :popup PopUp | ]]) @@ -4829,13 +4374,7 @@ describe('builtin popupmenu', function() {1:~ }{n: Select Line }{1: }| {1:~ }{n: Select Block }{1: }| {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 :popup PopUp | ]]) @@ -4859,13 +4398,7 @@ describe('builtin popupmenu', function() {1:~ }{n: Select Line }{1: }| {1:~ }{n: Select Block }{1: }| {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*7 changed | ]]) @@ -4875,22 +4408,7 @@ describe('builtin popupmenu', function() one two three four five | and one two {7:^X}three four five | one more two three four five | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*16 pasted | ]]) @@ -4911,12 +4429,7 @@ describe('builtin popupmenu', function() {1:~ }{n: Select Line }{1: }| {1:~ }{n: Select Block }{1: }| {1:~ }{n: Select All }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*6 :popup PopUp | ]]) @@ -4951,9 +4464,7 @@ describe('builtin popupmenu', function() {s:aword1 W extra text 1 }{1: }| {n:aword2 W extra text 2 }{1: }| {n:aword3 W extra text 3 }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- }{5:match 1 of 3} | ]]) end) @@ -4967,21 +4478,22 @@ describe('builtin popupmenu', function() hi PmenuExtraSel guifg=Black guibg=Grey ]]) local attrs = screen:get_default_attr_ids() - attrs.kn = {foreground = Screen.colors.Red, background = Screen.colors.Magenta} - attrs.ks = {foreground = Screen.colors.Red, background = Screen.colors.Grey} - attrs.xn = {foreground = Screen.colors.White, background = Screen.colors.Magenta} - attrs.xs = {foreground = Screen.colors.Black, background = Screen.colors.Grey} + attrs.kn = { foreground = Screen.colors.Red, background = Screen.colors.Magenta } + attrs.ks = { foreground = Screen.colors.Red, background = Screen.colors.Grey } + attrs.xn = { foreground = Screen.colors.White, background = Screen.colors.Magenta } + attrs.xs = { foreground = Screen.colors.Black, background = Screen.colors.Grey } feed('iaw<C-X><C-u>') - screen:expect([[ + screen:expect( + [[ aword1^ | {s:aword1 }{ks:W }{xs:extra text 1 }{1: }| {n:aword2 }{kn:W }{xn:extra text 2 }{1: }| {n:aword3 }{kn:W }{xn:extra text 3 }{1: }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 {2:-- }{5:match 1 of 3} | - ]], attrs) + ]], + attrs + ) end) end) end diff --git a/test/functional/ui/quickfix_spec.lua b/test/functional/ui/quickfix_spec.lua index df43871e60..40f8ef353a 100644 --- a/test/functional/ui/quickfix_spec.lua +++ b/test/functional/ui/quickfix_spec.lua @@ -1,9 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths +local clear, feed, api = helpers.clear, helpers.feed, helpers.api local insert, command = helpers.insert, helpers.command - describe('quickfix selection highlight', function() local screen @@ -14,20 +13,20 @@ describe('quickfix selection highlight', function() screen:attach() screen:set_default_attr_ids({ [1] = { bold = true, foreground = Screen.colors.Blue }, - [2] = {reverse = true}, - [3] = {foreground = Screen.colors.Brown}, - [4] = {bold = true, reverse = true}, - [5] = {background = Screen.colors.Green}, - [6] = {foreground = Screen.colors.Brown, background = Screen.colors.Green}, - [7] = {background = Screen.colors.Red}, - [8] = {foreground = Screen.colors.Brown, background = Screen.colors.Red}, - [9] = {background = Screen.colors.Fuchsia}, - [10] = {foreground = Screen.colors.Red, background = Screen.colors.Fuchsia}, - [11] = {foreground = Screen.colors.Red}, - [12] = {foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia}, + [2] = { reverse = true }, + [3] = { foreground = Screen.colors.Brown }, + [4] = { bold = true, reverse = true }, + [5] = { background = Screen.colors.Green }, + [6] = { foreground = Screen.colors.Brown, background = Screen.colors.Green }, + [7] = { background = Screen.colors.Red }, + [8] = { foreground = Screen.colors.Brown, background = Screen.colors.Red }, + [9] = { background = Screen.colors.Fuchsia }, + [10] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia }, + [11] = { foreground = Screen.colors.Red }, + [12] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia }, }) - meths.set_option_value('errorformat', '%m %l', {}) + api.nvim_set_option_value('errorformat', '%m %l', {}) command('syntax on') command('highlight Search guibg=Green') @@ -49,9 +48,7 @@ describe('quickfix selection highlight', function() Line 4 | Line 5 | | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 | ]]) end) @@ -89,7 +86,7 @@ describe('quickfix selection highlight', function() end) it('using QuickFixLine highlight group', function() - command('highlight QuickFixLine guibg=Red') + command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE') command('copen') @@ -124,7 +121,7 @@ describe('quickfix selection highlight', function() it('combines with CursorLine', function() command('set cursorline') - command('highlight QuickFixLine guifg=Red') + command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE') command('highlight CursorLine guibg=Fuchsia') command('copen') @@ -160,7 +157,7 @@ describe('quickfix selection highlight', function() it('QuickFixLine background takes precedence over CursorLine', function() command('set cursorline') - command('highlight QuickFixLine guibg=Red') + command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE') command('highlight CursorLine guibg=Fuchsia') command('copen') diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 810a68d387..e8d7d5c72d 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -72,23 +72,44 @@ local helpers = require('test.functional.helpers')(nil) local busted = require('busted') -local deepcopy = helpers.deepcopy +local deepcopy = vim.deepcopy local shallowcopy = helpers.shallowcopy local concat_tables = helpers.concat_tables -local pesc = helpers.pesc +local pesc = vim.pesc local run_session = helpers.run_session local eq = helpers.eq local dedent = helpers.dedent local get_session = helpers.get_session local create_callindex = helpers.create_callindex -local inspect = require('vim.inspect') +local inspect = vim.inspect local function isempty(v) return type(v) == 'table' and next(v) == nil end +--- @class test.functional.ui.screen.Grid +--- @field rows table[][] +--- @field width integer +--- @field height integer + --- @class test.functional.ui.screen +--- @field colors table<string,integer> +--- @field colornames table<integer,string> +--- @field uimeths table<string,function> +--- @field options? table<string,any> +--- @field timeout integer +--- @field win_position table<integer,table<string,integer>> +--- @field float_pos table<integer,table> +--- @field cmdline table<integer,table> +--- @field cmdline_block table[] +--- @field hl_groups table<string,integer> +--- @field messages table<integer,table> +--- @field private _cursor {grid:integer,row:integer,col:integer} +--- @field private _grids table<integer,test.functional.ui.screen.Grid> +--- @field private _grid_win_extmarks table<integer,table> +--- @field private _attr_table table<integer,table> +--- @field private _hl_info table<integer,table> local Screen = {} Screen.__index = Screen @@ -103,13 +124,14 @@ end local default_screen_timeout = default_timeout_factor * 3500 -function Screen._init_colors(session) +local function _init_colors() + local session = get_session() local status, rv = session:request('nvim_get_color_map') if not status then error('failed to get color map') end - local colors = rv - local colornames = {} + local colors = rv --- @type table<string,integer> + local colornames = {} --- @type table<integer,string> for name, rgb in pairs(colors) do -- we disregard the case that colornames might not be unique, as -- this is just a helper to get any canonical name of a color @@ -119,17 +141,14 @@ function Screen._init_colors(session) Screen.colornames = colornames end +--- @param width? integer +--- @param height? integer +--- @return test.functional.ui.screen function Screen.new(width, height) if not Screen.colors then - Screen._init_colors(get_session()) + _init_colors() end - if not width then - width = 53 - end - if not height then - height = 14 - end local self = setmetatable({ timeout = default_screen_timeout, title = '', @@ -140,6 +159,7 @@ function Screen.new(width, height) suspended = false, mode = 'normal', options = {}, + pwd = '', popupmenu = nil, cmdline = {}, cmdline_block = {}, @@ -161,30 +181,35 @@ function Screen.new(width, height) _default_attr_ids = nil, mouse_enabled = true, _attrs = {}, - _hl_info = {[0]={}}, - _attr_table = {[0]={{},{}}}, + _hl_info = { [0] = {} }, + _attr_table = { [0] = { {}, {} } }, _clear_attrs = nil, _new_attrs = false, - _width = width, - _height = height, + _width = width or 53, + _height = height or 14, _grids = {}, _grid_win_extmarks = {}, _cursor = { - grid = 1, row = 1, col = 1 + grid = 1, + row = 1, + col = 1, }, _busy = false, }, Screen) + local function ui(method, ...) if self.rpc_async then - self._session:notify('nvim_ui_'..method, ...) + self._session:notify('nvim_ui_' .. method, ...) else - local status, rv = self._session:request('nvim_ui_'..method, ...) + local status, rv = self._session:request('nvim_ui_' .. method, ...) if not status then error(rv[2]) end end end + self.uimeths = create_callindex(ui) + return self end @@ -200,13 +225,21 @@ function Screen:set_rgb_cterm(val) self._rgb_cterm = val end +--- @class test.functional.ui.screen.Opts +--- @field ext_linegrid? boolean +--- @field ext_multigrid? boolean +--- @field ext_newgrid? boolean +--- @field ext_popupmenu? boolean +--- @field ext_wildmenu? boolean +--- @field rgb? boolean +--- @field _debug_float? boolean + +--- @param options test.functional.ui.screen.Opts +--- @param session? test.Session function Screen:attach(options, session) - if session == nil then - session = get_session() - end - if options == nil then - options = {} - end + session = session or get_session() + options = options or {} + if options.ext_linegrid == nil then options.ext_linegrid = true end @@ -241,106 +274,178 @@ function Screen:try_resize_grid(grid, columns, rows) self.uimeths.try_resize_grid(grid, columns, rows) end +--- @param option 'ext_linegrid'|'ext_multigrid'|'ext_popupmenu'|'ext_wildmenu'|'rgb' +--- @param value boolean function Screen:set_option(option, value) self.uimeths.set_option(option, value) + --- @diagnostic disable-next-line:no-unknown self._options[option] = value end -- canonical order of ext keys, used to generate asserts local ext_keys = { - 'popupmenu', 'cmdline', 'cmdline_block', 'wildmenu_items', 'wildmenu_pos', - 'messages', 'msg_history', 'showmode', 'showcmd', 'ruler', 'float_pos', 'win_viewport' + 'popupmenu', + 'cmdline', + 'cmdline_block', + 'wildmenu_items', + 'wildmenu_pos', + 'messages', + 'msg_history', + 'showmode', + 'showcmd', + 'ruler', + 'float_pos', + 'win_viewport', } --- Asserts that the screen state eventually matches an expected state. --- --- Can be called with positional args: --- screen:expect(grid, [attr_ids]) --- screen:expect(condition) --- or keyword args (supports more options): --- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end} --- --- --- grid: Expected screen state (string). Each line represents a screen --- row. Last character of each row (typically "|") is stripped. --- Common indentation is stripped. --- "{MATCH:x}" in a line is matched against Lua pattern `x`. --- attr_ids: Expected text attributes. Screen rows are transformed according --- to this table, as follows: each substring S composed of --- characters having the same attributes will be substituted by --- "{K:S}", where K is a key in `attr_ids`. Any unexpected --- attributes in the final state are an error. --- Use screen:set_default_attr_ids() to define attributes for many --- expect() calls. --- extmarks: Expected win_extmarks accumulated for the grids. For each grid, --- the win_extmark messages are accumulated into an array. --- condition: Function asserting some arbitrary condition. Return value is --- ignored, throw an error (use eq() or similar) to signal failure. --- any: Lua pattern string expected to match a screen line. NB: the --- following chars are magic characters --- ( ) . % + - * ? [ ^ $ --- and must be escaped with a preceding % for a literal match. --- mode: Expected mode as signaled by "mode_change" event --- unchanged: Test that the screen state is unchanged since the previous --- expect(...). Any flush event resulting in a different state is --- considered an error. Not observing any events until timeout --- is acceptable. --- intermediate:Test that the final state is the same as the previous expect, --- but expect an intermediate state that is different. If possible --- it is better to use an explicit screen:expect(...) for this --- intermediate state. --- reset: Reset the state internal to the test Screen before starting to --- receive updates. This should be used after command("redraw!") --- or some other mechanism that will invoke "redraw!", to check --- that all screen state is transmitted again. This includes --- state related to ext_ features as mentioned below. --- timeout: maximum time that will be waited until the expected state is --- seen (or maximum time to observe an incorrect change when --- `unchanged` flag is used) --- --- The following keys should be used to expect the state of various ext_ --- features. Note that an absent key will assert that the item is currently --- NOT present on the screen, also when positional form is used. --- --- popupmenu: Expected ext_popupmenu state, --- cmdline: Expected ext_cmdline state, as an array of cmdlines of --- different level. --- cmdline_block: Expected ext_cmdline block (for function definitions) --- wildmenu_items: Expected items for ext_wildmenu --- wildmenu_pos: Expected position for ext_wildmenu +local expect_keys = { + grid = true, + attr_ids = true, + condition = true, + mouse_enabled = true, + any = true, + mode = true, + unchanged = true, + intermediate = true, + reset = true, + timeout = true, + request_cb = true, + hl_groups = true, + extmarks = true, +} + +for _, v in ipairs(ext_keys) do + expect_keys[v] = true +end + +--- @class test.function.ui.screen.Expect +--- +--- Expected screen state (string). Each line represents a screen +--- row. Last character of each row (typically "|") is stripped. +--- Common indentation is stripped. +--- "{MATCH:x}" in a line is matched against Lua pattern `x`. +--- "*n" at the end of a line means it repeats `n` times. +--- @field grid? string +--- +--- Expected text attributes. Screen rows are transformed according +--- to this table, as follows: each substring S composed of +--- characters having the same attributes will be substituted by +--- "{K:S}", where K is a key in `attr_ids`. Any unexpected +--- attributes in the final state are an error. +--- Use an empty table for a text-only (no attributes) expectation. +--- Use screen:set_default_attr_ids() to define attributes for many +--- expect() calls. +--- @field attr_ids? table<integer,table<string,any>> +--- +--- Expected win_extmarks accumulated for the grids. For each grid, +--- the win_extmark messages are accumulated into an array. +--- @field extmarks? table<integer,table> +--- +--- Function asserting some arbitrary condition. Return value is +--- ignored, throw an error (use eq() or similar) to signal failure. +--- @field condition? fun() +--- +--- Lua pattern string expected to match a screen line. NB: the +--- following chars are magic characters +--- ( ) . % + - * ? [ ^ $ +--- and must be escaped with a preceding % for a literal match. +--- @field any? string +--- +--- Expected mode as signaled by "mode_change" event +--- @field mode? string +--- +--- Test that the screen state is unchanged since the previous +--- expect(...). Any flush event resulting in a different state is +--- considered an error. Not observing any events until timeout +--- is acceptable. +--- @field unchanged? boolean +--- +--- Test that the final state is the same as the previous expect, +--- but expect an intermediate state that is different. If possible +--- it is better to use an explicit screen:expect(...) for this +--- intermediate state. +--- @field intermediate? boolean +--- +--- Reset the state internal to the test Screen before starting to +--- receive updates. This should be used after command("redraw!") +--- or some other mechanism that will invoke "redraw!", to check +--- that all screen state is transmitted again. This includes +--- state related to ext_ features as mentioned below. +--- @field reset? boolean +--- +--- maximum time that will be waited until the expected state is +--- seen (or maximum time to observe an incorrect change when +--- `unchanged` flag is used) +--- @field timeout? integer +--- +--- @field mouse_enabled? boolean +--- +--- @field win_viewport? table<integer,table<string,integer>> +--- @field float_pos? {[1]:integer,[2]:integer} +--- @field hl_groups? table<string,integer> +--- +--- The following keys should be used to expect the state of various ext_ +--- features. Note that an absent key will assert that the item is currently +--- NOT present on the screen, also when positional form is used. +--- +--- Expected ext_popupmenu state, +--- @field popupmenu? table +--- +--- Expected ext_cmdline state, as an array of cmdlines of +--- different level. +--- @field cmdline? table +--- +--- Expected ext_cmdline block (for function definitions) +--- @field cmdline_block? table +--- +--- items for ext_wildmenu +--- @field wildmenu_items? table +--- +--- position for ext_wildmenu +--- @field wildmenu_pos? table + +--- Asserts that the screen state eventually matches an expected state. +--- +--- Can be called with positional args: +--- screen:expect(grid, [attr_ids]) +--- screen:expect(condition) +--- or keyword args (supports more options): +--- screen:expect{grid=[[...]], cmdline={...}, condition=function() ... end} +--- +--- @param expected string|function|test.function.ui.screen.Expect +--- @param attr_ids? table<integer,table<string,any>> function Screen:expect(expected, attr_ids, ...) - local grid, condition = nil, nil - local expected_rows = {} - assert(next({...}) == nil, "invalid args to expect()") - if type(expected) == "table" then - assert(not (attr_ids ~= nil)) - local is_key = {grid=true, attr_ids=true, condition=true, mouse_enabled=true, - any=true, mode=true, unchanged=true, intermediate=true, - reset=true, timeout=true, request_cb=true, hl_groups=true, extmarks=true} - for _, v in ipairs(ext_keys) do - is_key[v] = true - end - for k, _ in pairs(expected) do - if not is_key[k] then - error("Screen:expect: Unknown keyword argument '"..k.."'") + --- @type string, fun() + local grid, condition + + assert(next({ ... }) == nil, 'invalid args to expect()') + + if type(expected) == 'table' then + assert(attr_ids == nil) + for k, _ in + pairs(expected --[[@as table<string,any>]]) + do + if not expect_keys[k] then + error("Screen:expect: Unknown keyword argument '" .. k .. "'") end end grid = expected.grid attr_ids = expected.attr_ids condition = expected.condition - assert(not (expected.any ~= nil and grid ~= nil)) - elseif type(expected) == "string" then + assert(expected.any == nil or grid == nil) + elseif type(expected) == 'string' then grid = expected expected = {} - elseif type(expected) == "function" then - assert(not (attr_ids ~= nil)) + elseif type(expected) == 'function' then + assert(attr_ids == nil) condition = expected expected = {} else assert(false) end - if grid ~= nil then + local expected_rows = {} --- @type string[] + if grid then -- Remove the last line and dedent. Note that gsub returns more then one -- value. grid = dedent(grid:gsub('\n[ ]+$', ''), 0) @@ -348,15 +453,23 @@ function Screen:expect(expected, attr_ids, ...) table.insert(expected_rows, row) end end + local attr_state = { - ids = attr_ids or self._default_attr_ids, + ids = attr_ids or self._default_attr_ids, } + + if isempty(attr_ids) then + attr_state.ids = nil + end + if self._options.ext_linegrid then attr_state.id_to_index = self:linegrid_check_attrs(attr_state.ids or {}) end + self._new_attrs = false self:_wait(function() - if condition ~= nil then + if condition then + --- @type boolean, string local status, res = pcall(condition) if not status then return tostring(res) @@ -369,27 +482,47 @@ function Screen:expect(expected, attr_ids, ...) local actual_rows = self:render(not expected.any, attr_state) - if expected.any ~= nil then + if expected.any then -- Search for `any` anywhere in the screen lines. local actual_screen_str = table.concat(actual_rows, '\n') - if nil == string.find(actual_screen_str, expected.any) then + if not actual_screen_str:find(expected.any) then return ( 'Failed to match any screen lines.\n' - .. 'Expected (anywhere): "' .. expected.any .. '"\n' - .. 'Actual:\n |' .. table.concat(actual_rows, '\n |') .. '\n\n') + .. 'Expected (anywhere): "' + .. expected.any + .. '"\n' + .. 'Actual:\n |' + .. table.concat(actual_rows, '\n |') + .. '\n\n' + ) end end - if grid ~= nil then - local err_msg, msg_expected_rows = nil, {} + if grid then + for i, row in ipairs(expected_rows) do + local count --- @type integer? + row, count = row:match('^(.*%|)%*(%d+)$') + if row then + count = tonumber(count) + table.remove(expected_rows, i) + for _ = 1, count do + table.insert(expected_rows, i, row) + end + end + end + local err_msg = nil -- `expected` must match the screen lines exactly. if #actual_rows ~= #expected_rows then - err_msg = "Expected screen height " .. #expected_rows - .. ' differs from actual height ' .. #actual_rows .. '.' + err_msg = 'Expected screen height ' + .. #expected_rows + .. ' differs from actual height ' + .. #actual_rows + .. '.' end + local msg_expected_rows = shallowcopy(expected_rows) + local msg_actual_rows = shallowcopy(actual_rows) for i, row in ipairs(expected_rows) do - msg_expected_rows[i] = row - local pat = nil + local pat = nil --- @type string? if actual_rows[i] and row ~= actual_rows[i] then local after = row while true do @@ -398,6 +531,7 @@ function Screen:expect(expected, attr_ids, ...) pat = pat and (pat .. pesc(after)) break end + --- @type string pat = (pat or '') .. pesc(after:sub(1, s - 1)) .. m after = after:sub(e + 1) end @@ -405,7 +539,7 @@ function Screen:expect(expected, attr_ids, ...) if row ~= actual_rows[i] and (not pat or not actual_rows[i]:match(pat)) then msg_expected_rows[i] = '*' .. msg_expected_rows[i] if i <= #actual_rows then - actual_rows[i] = '*' .. actual_rows[i] + msg_actual_rows[i] = '*' .. msg_actual_rows[i] end if err_msg == nil then err_msg = 'Row ' .. tostring(i) .. ' did not match.' @@ -414,11 +548,18 @@ function Screen:expect(expected, attr_ids, ...) end if err_msg ~= nil then return ( - err_msg..'\nExpected:\n |'..table.concat(msg_expected_rows, '\n |')..'\n' - ..'Actual:\n |'..table.concat(actual_rows, '\n |')..'\n\n'..[[ + err_msg + .. '\nExpected:\n |' + .. table.concat(msg_expected_rows, '\n |') + .. '\n' + .. 'Actual:\n |' + .. table.concat(msg_actual_rows, '\n |') + .. '\n\n' + .. [[ To print the expect() call that would assert the current screen state, use screen:snapshot_util(). In case of non-deterministic failures, use -screen:redraw_debug() to show all intermediate screen states. ]]) +screen:redraw_debug() to show all intermediate screen states.]] + ) end end @@ -447,12 +588,18 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end -- Convert assertion errors into invalid screen state descriptions. - for _, k in ipairs(concat_tables(ext_keys, {'mode', 'mouse_enabled'})) do + for _, k in ipairs(concat_tables(ext_keys, { 'mode', 'mouse_enabled' })) do -- Empty states are considered the default and need not be mentioned. - if (not (expected[k] == nil and isempty(extstate[k]))) then + if not (expected[k] == nil and isempty(extstate[k])) then local status, res = pcall(eq, expected[k], extstate[k], k) if not status then - return (tostring(res)..'\nHint: full state of "'..k..'":\n '..inspect(extstate[k])) + return ( + tostring(res) + .. '\nHint: full state of "' + .. k + .. '":\n ' + .. inspect(extstate[k]) + ) end end end @@ -461,7 +608,7 @@ screen:redraw_debug() to show all intermediate screen states. ]]) for name, id in pairs(expected.hl_groups) do local expected_hl = attr_state.ids[id] local actual_hl = self._attr_table[self.hl_groups[name]][(self._options.rgb and 1) or 2] - local status, res = pcall(eq, expected_hl, actual_hl, "highlight "..name) + local status, res = pcall(eq, expected_hl, actual_hl, 'highlight ' .. name) if not status then return tostring(res) end @@ -472,9 +619,10 @@ screen:redraw_debug() to show all intermediate screen states. ]]) for gridid, expected_marks in pairs(expected.extmarks) do local stored_marks = self._grid_win_extmarks[gridid] if stored_marks == nil then - return 'no win_extmark for grid '..tostring(gridid) + return 'no win_extmark for grid ' .. tostring(gridid) end - local status, res = pcall(eq, expected_marks, stored_marks, "extmarks for grid "..tostring(gridid)) + local status, res = + pcall(eq, expected_marks, stored_marks, 'extmarks for grid ' .. tostring(gridid)) if not status then return tostring(res) end @@ -482,7 +630,7 @@ screen:redraw_debug() to show all intermediate screen states. ]]) for gridid, _ in pairs(self._grid_win_extmarks) do local expected_marks = expected.extmarks[gridid] if expected_marks == nil then - return 'unexpected win_extmark for grid '..tostring(gridid) + return 'unexpected win_extmark for grid ' .. tostring(gridid) end end end @@ -490,7 +638,6 @@ screen:redraw_debug() to show all intermediate screen states. ]]) end function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs) - waittime_ms = waittime_ms and waittime_ms or 100 -- Collect the current screen state. local kwargs = self:get_snapshot(nil, ignore_attrs) @@ -505,8 +652,12 @@ function Screen:expect_unchanged(intermediate, waittime_ms, ignore_attrs) self:expect(kwargs) end +--- @private +--- @param check fun(): string +--- @param flags table<string,any> function Screen:_wait(check, flags) - local err, checked = false, false + local err --- @type string? + local checked = false local success_seen = false local failure_after_success = false local did_flush = true @@ -537,16 +688,18 @@ function Screen:_wait(check, flags) -- For an "unchanged" test, flags.timeout is the time during which the state -- must not change, so always wait this full time. - if (flags.unchanged or flags.intermediate) and flags.timeout ~= nil then - minimal_timeout = timeout + if flags.unchanged then + minimal_timeout = flags.timeout or default_timeout_factor * 20 end assert(timeout >= minimal_timeout) local did_minimal_timeout = false local function notification_cb(method, args) - assert(method == 'redraw', string.format( - 'notification_cb: unexpected method (%s, args=%s)', method, inspect(args))) + assert( + method == 'redraw', + string.format('notification_cb: unexpected method (%s, args=%s)', method, inspect(args)) + ) did_flush = self:_redraw(args) if not did_flush then return @@ -557,12 +710,12 @@ function Screen:_wait(check, flags) intermediate_seen = true end - if not err then + if not err and (not flags.intermediate or intermediate_seen) then success_seen = true if did_minimal_timeout then self._session:stop() end - elseif success_seen and #args > 0 then + elseif err and success_seen and #args > 0 then success_seen = false failure_after_success = true -- print(inspect(args)) @@ -572,7 +725,7 @@ function Screen:_wait(check, flags) end local eof = run_session(self._session, flags.request_cb, notification_cb, nil, minimal_timeout) if not did_flush then - err = "no flush received" + err = 'no flush received' elseif not checked then err = check() if not err and flags.unchanged then @@ -583,12 +736,13 @@ function Screen:_wait(check, flags) if not success_seen and not eof then did_minimal_timeout = true - eof = run_session(self._session, flags.request_cb, notification_cb, nil, timeout-minimal_timeout) + eof = + run_session(self._session, flags.request_cb, notification_cb, nil, timeout - minimal_timeout) end local did_warn = false if warn_immediate and immediate_seen then - print([[ + print([[ warning: Screen test succeeded immediately. Try to avoid this unless the purpose of the test really requires it.]]) @@ -622,21 +776,24 @@ between asynchronous (feed(), nvim_input()) and synchronous API calls. did_warn = true end - if err then - if eof then err = err..'\n\n'..eof[2] end - busted.fail(err, 3) + if eof then + err = err .. '\n\n' .. eof[2] + end + busted.fail(err .. '\n\nSnapshot:\n' .. self:_print_snapshot(), 3) elseif did_warn then - if eof then print(eof[2]) end + if eof then + print(eof[2]) + end local tb = debug.traceback() local index = string.find(tb, '\n%s*%[C]') - print(string.sub(tb,1,index)) + print(string.sub(tb, 1, index)) end if flags.intermediate then - assert(intermediate_seen, "expected intermediate screen state before final screen state") + assert(intermediate_seen, 'expected intermediate screen state before final screen state') elseif flags.unchanged then - assert(not intermediate_seen, "expected screen state to be unchanged") + assert(not intermediate_seen, 'expected screen state to be unchanged') end end @@ -648,23 +805,31 @@ function Screen:sleep(ms, request_cb) run_session(self._session, request_cb, notification_cb, nil, ms) end +--- @private +--- @param updates {[1]:string, [integer]:any[]}[] function Screen:_redraw(updates) local did_flush = false for k, update in ipairs(updates) do -- print('--', inspect(update)) local method = update[1] for i = 2, #update do - local handler_name = '_handle_'..method + local handler_name = '_handle_' .. method + --- @type function local handler = self[handler_name] - assert(handler ~= nil, "missing handler: Screen:"..handler_name) + assert(handler ~= nil, 'missing handler: Screen:' .. handler_name) local status, res = pcall(handler, self, unpack(update[i])) if not status then - error(handler_name..' failed' - ..'\n payload: '..inspect(update) - ..'\n error: '..tostring(res)) + error( + handler_name + .. ' failed' + .. '\n payload: ' + .. inspect(update) + .. '\n error: ' + .. tostring(res) + ) end end - if k == #updates and method == "flush" then + if k == #updates and method == 'flush' then did_flush = true end end @@ -674,12 +839,15 @@ end function Screen:_handle_resize(width, height) self:_handle_grid_resize(1, width, height) self._scroll_region = { - top = 1, bot = height, left = 1, right = width + top = 1, + bot = height, + left = 1, + right = width, } self._grid = self._grids[1] end -local function min(x,y) +local function min(x, y) if x < y then return x else @@ -692,14 +860,14 @@ function Screen:_handle_grid_resize(grid, width, height) for _ = 1, height do local cols = {} for _ = 1, width do - table.insert(cols, {text = ' ', attrs = self._clear_attrs, hl_id = 0}) + table.insert(cols, { text = ' ', attrs = self._clear_attrs, hl_id = 0 }) end table.insert(rows, cols) end if grid > 1 and self._grids[grid] ~= nil then local old = self._grids[grid] - for i = 1, min(height,old.height) do - for j = 1, min(width,old.width) do + for i = 1, min(height, old.height) do + for j = 1, min(width, old.width) do rows[i][j] = old.rows[i][j] end end @@ -710,13 +878,12 @@ function Screen:_handle_grid_resize(grid, width, height) self._cursor.col = 1 end self._grids[grid] = { - rows=rows, - width=width, - height=height, + rows = rows, + width = width, + height = height, } end - function Screen:_handle_msg_set_pos(grid, row, scrolled, char) self.msg_grid = grid self.msg_grid_pos = row @@ -724,8 +891,7 @@ function Screen:_handle_msg_set_pos(grid, row, scrolled, char) self.msg_sep_char = char end -function Screen:_handle_flush() -end +function Screen:_handle_flush() end function Screen:_reset() -- TODO: generalize to multigrid later @@ -740,18 +906,20 @@ function Screen:_reset() self._grid_win_extmarks = {} end +--- @param cursor_style_enabled boolean +--- @param mode_info table[] function Screen:_handle_mode_info_set(cursor_style_enabled, mode_info) self._cursor_style_enabled = cursor_style_enabled for _, item in pairs(mode_info) do - -- attr IDs are not stable, but their value should be - if item.attr_id ~= nil then - item.attr = self._attr_table[item.attr_id][1] - item.attr_id = nil - end - if item.attr_id_lm ~= nil then - item.attr_lm = self._attr_table[item.attr_id_lm][1] - item.attr_id_lm = nil - end + -- attr IDs are not stable, but their value should be + if item.attr_id ~= nil then + item.attr = self._attr_table[item.attr_id][1] + item.attr_id = nil + end + if item.attr_id_lm ~= nil then + item.attr_lm = self._attr_table[item.attr_id_lm][1] + item.attr_id_lm = nil + end end self._mode_info = mode_info end @@ -763,7 +931,10 @@ function Screen:_handle_clear() -- newer clients, to check we remain compatible with both kind of clients, -- ensure the scroll region is in a reset state. local expected_region = { - top = 1, bot = self._grid.height, left = 1, right = self._grid.width + top = 1, + bot = self._grid.height, + left = 1, + right = self._grid.width, } eq(expected_region, self._scroll_region) self:_handle_grid_clear(1) @@ -804,14 +975,24 @@ function Screen:_handle_win_pos(grid, win, startrow, startcol, width, height) startrow = startrow, startcol = startcol, width = width, - height = height + height = height, } self.float_pos[grid] = nil end -function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curcol, linecount, scroll_delta) +function Screen:_handle_win_viewport( + grid, + win, + topline, + botline, + curline, + curcol, + linecount, + scroll_delta +) -- accumulate scroll delta - local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta or 0 + local last_scroll_delta = self.win_viewport[grid] and self.win_viewport[grid].sum_scroll_delta + or 0 self.win_viewport[grid] = { win = win, topline = topline, @@ -819,18 +1000,18 @@ function Screen:_handle_win_viewport(grid, win, topline, botline, curline, curco curline = curline, curcol = curcol, linecount = linecount, - sum_scroll_delta = scroll_delta + last_scroll_delta + sum_scroll_delta = scroll_delta + last_scroll_delta, } end function Screen:_handle_win_float_pos(grid, ...) self.win_position[grid] = nil - self.float_pos[grid] = {...} + self.float_pos[grid] = { ... } end function Screen:_handle_win_external_pos(grid) self.win_position[grid] = nil - self.float_pos[grid] = {external=true} + self.float_pos[grid] = { external = true } end function Screen:_handle_win_hide(grid) @@ -846,7 +1027,7 @@ function Screen:_handle_win_extmark(grid, ...) if self._grid_win_extmarks[grid] == nil then self._grid_win_extmarks[grid] = {} end - table.insert(self._grid_win_extmarks[grid], {...}) + table.insert(self._grid_win_extmarks[grid], { ... }) end function Screen:_handle_busy_start() @@ -866,7 +1047,7 @@ function Screen:_handle_mouse_off() end function Screen:_handle_mode_change(mode, idx) - assert(mode == self._mode_info[idx+1].name) + assert(mode == self._mode_info[idx + 1].name) self.mode = mode end @@ -882,17 +1063,24 @@ function Screen:_handle_scroll(count) local bot = self._scroll_region.bot local left = self._scroll_region.left local right = self._scroll_region.right - self:_handle_grid_scroll(1, top-1, bot, left-1, right, count, 0) + self:_handle_grid_scroll(1, top - 1, bot, left - 1, right, count, 0) end +--- @param g any +--- @param top integer +--- @param bot integer +--- @param left integer +--- @param right integer +--- @param rows integer +--- @param cols integer function Screen:_handle_grid_scroll(g, top, bot, left, right, rows, cols) - top = top+1 - left = left+1 + top = top + 1 + left = left + 1 assert(cols == 0) local grid = self._grids[g] + --- @type integer, integer, integer local start, stop, step - if rows > 0 then start = top stop = bot - rows @@ -921,11 +1109,13 @@ function Screen:_handle_grid_scroll(g, top, bot, left, right, rows, cols) end function Screen:_handle_hl_attr_define(id, rgb_attrs, cterm_attrs, info) - self._attr_table[id] = {rgb_attrs, cterm_attrs} + self._attr_table[id] = { rgb_attrs, cterm_attrs } self._hl_info[id] = info self._new_attrs = true end +--- @param name string +--- @param id integer function Screen:_handle_hl_group_set(name, id) self.hl_groups[name] = id end @@ -933,9 +1123,8 @@ end function Screen:get_hl(val) if self._options.ext_newgrid then return self._attr_table[val][1] - else - return val end + return val end function Screen:_handle_highlight_set(attrs) @@ -951,14 +1140,18 @@ function Screen:_handle_put(str) self._cursor.col = self._cursor.col + 1 end +--- @param grid integer +--- @param row integer +--- @param col integer +--- @param items integer[][] function Screen:_handle_grid_line(grid, row, col, items) assert(self._options.ext_linegrid) assert(#items > 0) - local line = self._grids[grid].rows[row+1] - local colpos = col+1 + local line = self._grids[grid].rows[row + 1] + local colpos = col + 1 local hl_id = 0 - for _,item in ipairs(items) do - local text, hl_id_cell, count = unpack(item) + for _, item in ipairs(items) do + local text, hl_id_cell, count = item[1], item[2], item[3] if hl_id_cell ~= nil then hl_id = hl_id_cell end @@ -966,7 +1159,7 @@ function Screen:_handle_grid_line(grid, row, col, items) local cell = line[colpos] cell.text = text cell.hl_id = hl_id - colpos = colpos+1 + colpos = colpos + 1 end end end @@ -981,11 +1174,11 @@ end function Screen:_handle_default_colors_set(rgb_fg, rgb_bg, rgb_sp, cterm_fg, cterm_bg) self.default_colors = { - rgb_fg=rgb_fg, - rgb_bg=rgb_bg, - rgb_sp=rgb_sp, - cterm_fg=cterm_fg, - cterm_bg=cterm_bg + rgb_fg = rgb_fg, + rgb_bg = rgb_bg, + rgb_sp = rgb_sp, + cterm_fg = cterm_fg, + cterm_bg = cterm_bg, } end @@ -1021,8 +1214,12 @@ function Screen:_handle_option_set(name, value) self.options[name] = value end +function Screen:_handle_chdir(path) + self.pwd = vim.fs.normalize(path, { expand_env = false }) +end + function Screen:_handle_popupmenu_show(items, selected, row, col, grid) - self.popupmenu = {items=items, pos=selected, anchor={grid, row, col}} + self.popupmenu = { items = items, pos = selected, anchor = { grid, row, col } } end function Screen:_handle_popupmenu_select(selected) @@ -1034,9 +1231,15 @@ function Screen:_handle_popupmenu_hide() end function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level) - if firstc == '' then firstc = nil end - if prompt == '' then prompt = nil end - if indent == 0 then indent = nil end + if firstc == '' then + firstc = nil + end + if prompt == '' then + prompt = nil + end + if indent == 0 then + indent = nil + end -- check position is valid #10000 local len = 0 @@ -1045,8 +1248,13 @@ function Screen:_handle_cmdline_show(content, pos, firstc, prompt, indent, level end assert(pos <= len) - self.cmdline[level] = {content=content, pos=pos, firstc=firstc, - prompt=prompt, indent=indent} + self.cmdline[level] = { + content = content, + pos = pos, + firstc = firstc, + prompt = prompt, + indent = indent, + } end function Screen:_handle_cmdline_hide(level) @@ -1055,7 +1263,7 @@ end function Screen:_handle_cmdline_special_char(char, shift, level) -- cleared by next cmdline_show on the same level - self.cmdline[level].special = {char, shift} + self.cmdline[level].special = { char, shift } end function Screen:_handle_cmdline_pos(pos, level) @@ -1067,7 +1275,7 @@ function Screen:_handle_cmdline_block_show(block) end function Screen:_handle_cmdline_block_append(item) - self.cmdline_block[#self.cmdline_block+1] = item + self.cmdline_block[#self.cmdline_block + 1] = item end function Screen:_handle_cmdline_block_hide() @@ -1091,7 +1299,7 @@ function Screen:_handle_msg_show(kind, chunks, replace_last) if not replace_last or pos == 0 then pos = pos + 1 end - self.messages[pos] = {kind=kind, content=chunks} + self.messages[pos] = { kind = kind, content = chunks } end function Screen:_handle_msg_clear() @@ -1140,19 +1348,23 @@ function Screen:_row_repr(gridnr, rownr, attr_state, cursor) local has_windows = self._options.ext_multigrid and gridnr == 1 local row = self._grids[gridnr].rows[rownr] if has_windows and self.msg_grid and self.msg_grid_pos < rownr then - return '['..self.msg_grid..':'..string.rep('-',#row)..']' + return '[' .. self.msg_grid .. ':' .. string.rep('-', #row) .. ']' end while i <= #row do local did_window = false if has_windows then - for id,pos in pairs(self.win_position) do - if i-1 == pos.startcol and pos.startrow <= rownr-1 and rownr-1 < pos.startrow + pos.height then + for id, pos in pairs(self.win_position) do + if + i - 1 == pos.startcol + and pos.startrow <= rownr - 1 + and rownr - 1 < pos.startrow + pos.height + then if current_attr_id then -- close current attribute bracket table.insert(rv, '}') current_attr_id = nil end - table.insert(rv, '['..id..':'..string.rep('-',pos.width)..']') + table.insert(rv, '[' .. id .. ':' .. string.rep('-', pos.width) .. ']') i = i + pos.width did_window = true end @@ -1183,7 +1395,7 @@ function Screen:_row_repr(gridnr, rownr, attr_state, cursor) end -- return the line representation, but remove empty attribute brackets and -- trailing whitespace - return table.concat(rv, '')--:gsub('%s+$', '') + return table.concat(rv, '') --:gsub('%s+$', '') end function Screen:_extstate_repr(attr_state) @@ -1201,29 +1413,29 @@ function Screen:_extstate_repr(attr_state) local messages = {} for i, entry in ipairs(self.messages) do - messages[i] = {kind=entry.kind, content=self:_chunks_repr(entry.content, attr_state)} + messages[i] = { kind = entry.kind, content = self:_chunks_repr(entry.content, attr_state) } end local msg_history = {} for i, entry in ipairs(self.msg_history) do - msg_history[i] = {kind=entry[1], content=self:_chunks_repr(entry[2], attr_state)} + msg_history[i] = { kind = entry[1], content = self:_chunks_repr(entry[2], attr_state) } end local win_viewport = (next(self.win_viewport) and self.win_viewport) or nil return { - popupmenu=self.popupmenu, - cmdline=cmdline, - cmdline_block=cmdline_block, - wildmenu_items=self.wildmenu_items, - wildmenu_pos=self.wildmenu_pos, - messages=messages, - showmode=self:_chunks_repr(self.showmode, attr_state), - showcmd=self:_chunks_repr(self.showcmd, attr_state), - ruler=self:_chunks_repr(self.ruler, attr_state), - msg_history=msg_history, - float_pos=self.float_pos, - win_viewport=win_viewport, + popupmenu = self.popupmenu, + cmdline = cmdline, + cmdline_block = cmdline_block, + wildmenu_items = self.wildmenu_items, + wildmenu_pos = self.wildmenu_pos, + messages = messages, + showmode = self:_chunks_repr(self.showmode, attr_state), + showcmd = self:_chunks_repr(self.showcmd, attr_state), + ruler = self:_chunks_repr(self.ruler, attr_state), + msg_history = msg_history, + float_pos = self.float_pos, + win_viewport = win_viewport, } end @@ -1238,14 +1450,14 @@ function Screen:_chunks_repr(chunks, attr_state) attrs = hl end local attr_id = self:_get_attr_id(attr_state, attrs, hl) - repr_chunks[i] = {text, attr_id} + repr_chunks[i] = { text, attr_id } end return repr_chunks end -- Generates tests. Call it where Screen:expect() would be. Waits briefly, then -- dumps the current screen state in the form of Screen:expect(). --- Use snapshot_util({},true) to generate a text-only (no attributes) test. +-- Use snapshot_util({}) to generate a text-only (no attributes) test. -- -- @see Screen:redraw_debug() function Screen:snapshot_util(attrs, ignore, request_cb) @@ -1259,7 +1471,7 @@ function Screen:redraw_debug(attrs, ignore, timeout) assert(method == 'redraw') for _, update in ipairs(args) do -- mode_info_set is quite verbose, comment out the condition to debug it. - if update[1] ~= "mode_info_set" then + if update[1] ~= 'mode_info_set' then print(inspect(update)) end end @@ -1273,17 +1485,25 @@ function Screen:redraw_debug(attrs, ignore, timeout) run_session(self._session, nil, notification_cb, nil, timeout) end +--- @param headers boolean +--- @param attr_state any +--- @param preview? boolean +--- @return string[] function Screen:render(headers, attr_state, preview) headers = headers and (self._options.ext_multigrid or self._options._debug_float) local rv = {} - for igrid,grid in vim.spairs(self._grids) do + for igrid, grid in vim.spairs(self._grids) do if headers then - local suffix = "" - if igrid > 1 and self.win_position[igrid] == nil - and self.float_pos[igrid] == nil and self.msg_grid ~= igrid then - suffix = " (hidden)" + local suffix = '' + if + igrid > 1 + and self.win_position[igrid] == nil + and self.float_pos[igrid] == nil + and self.msg_grid ~= igrid + then + suffix = ' (hidden)' end - table.insert(rv, "## grid "..igrid..suffix) + table.insert(rv, '## grid ' .. igrid .. suffix) end local height = grid.height if igrid == self.msg_grid then @@ -1291,8 +1511,8 @@ function Screen:render(headers, attr_state, preview) end for i = 1, height do local cursor = self._cursor.grid == igrid and self._cursor.row == i - local prefix = (headers or preview) and " " or "" - table.insert(rv, prefix..self:_row_repr(igrid, i, attr_state, cursor).."|") + local prefix = (headers or preview) and ' ' or '' + table.insert(rv, prefix .. self:_row_repr(igrid, i, attr_state, cursor) .. '|') end end return rv @@ -1301,15 +1521,22 @@ end -- Returns the current screen state in the form of a screen:expect() -- keyword-args map. function Screen:get_snapshot(attrs, ignore) - attrs = attrs or self._default_attr_ids if ignore == nil then ignore = self._default_attr_ignore end local attr_state = { - ids = {}, - ignore = ignore, - mutable = true, -- allow _row_repr to add missing highlights + ids = {}, + ignore = ignore, + mutable = true, -- allow _row_repr to add missing highlights } + if attrs == nil then + attrs = self._default_attr_ids + elseif isempty(attrs) then + attrs = nil + attr_state.ids = nil + else + attr_state.modified = true + end if attrs ~= nil then for i, a in pairs(attrs) do @@ -1317,11 +1544,22 @@ function Screen:get_snapshot(attrs, ignore) end end if self._options.ext_linegrid then - attr_state.id_to_index = self:linegrid_check_attrs(attr_state.ids) + attr_state.id_to_index = self:linegrid_check_attrs(attr_state.ids or {}) end local lines = self:render(true, attr_state, true) + for i, row in ipairs(lines) do + local count = 1 + while i < #lines and lines[i + 1] == row do + count = count + 1 + table.remove(lines, i + 1) + end + if count > 1 then + lines[i] = lines[i] .. '*' .. count + end + end + local ext_state = self:_extstate_repr(attr_state) for k, v in pairs(ext_state) do if isempty(v) then @@ -1353,33 +1591,50 @@ local function fmt_ext_state(name, state) return item end end - if name == "win_viewport" then - local str = "{\n" - for k,v in pairs(state) do - str = (str.." ["..k.."] = {win = {id = "..v.win.id.."}, topline = " - ..v.topline..", botline = "..v.botline..", curline = "..v.curline - ..", curcol = "..v.curcol..", linecount = "..v.linecount..", sum_scroll_delta = "..v.sum_scroll_delta.."};\n") + if name == 'win_viewport' then + local str = '{\n' + for k, v in pairs(state) do + str = ( + str + .. ' [' + .. k + .. '] = {win = ' + .. v.win + .. ', topline = ' + .. v.topline + .. ', botline = ' + .. v.botline + .. ', curline = ' + .. v.curline + .. ', curcol = ' + .. v.curcol + .. ', linecount = ' + .. v.linecount + .. ', sum_scroll_delta = ' + .. v.sum_scroll_delta + .. '};\n' + ) end - return str .. "}" - elseif name == "float_pos" then - local str = "{\n" - for k,v in pairs(state) do - str = str.." ["..k.."] = {{id = "..v[1].id.."}" + return str .. '}' + elseif name == 'float_pos' then + local str = '{\n' + for k, v in pairs(state) do + str = str .. ' [' .. k .. '] = {' .. v[1] for i = 2, #v do - str = str..", "..inspect(v[i]) + str = str .. ', ' .. inspect(v[i]) end - str = str .. "};\n" + str = str .. '};\n' end - return str .. "}" + return str .. '}' else -- TODO(bfredl): improve formatting of more states - return inspect(state,{process=remove_all_metatables}) + return inspect(state, { process = remove_all_metatables }) end end -function Screen:print_snapshot(attrs, ignore) +function Screen:_print_snapshot(attrs, ignore) local kwargs, ext_state, attr_state = self:get_snapshot(attrs, ignore) - local attrstr = "" + local attrstr = '' if attr_state.modified then local attrstrs = {} for i, a in pairs(attr_state.ids) do @@ -1387,23 +1642,29 @@ function Screen:print_snapshot(attrs, ignore) if self._options.ext_linegrid then dict = self:_pprint_hlitem(a) else - dict = "{"..self:_pprint_attrs(a).."}" + dict = '{' .. self:_pprint_attrs(a) .. '}' end - local keyval = (type(i) == "number") and "["..tostring(i).."]" or i - table.insert(attrstrs, " "..keyval.." = "..dict..";") + local keyval = (type(i) == 'number') and '[' .. tostring(i) .. ']' or i + table.insert(attrstrs, ' ' .. keyval .. ' = ' .. dict .. ';') end - attrstr = (", attr_ids={\n"..table.concat(attrstrs, "\n").."\n}") + attrstr = (', attr_ids={\n' .. table.concat(attrstrs, '\n') .. '\n}') + elseif isempty(attrs) then + attrstr = ', attr_ids={}' end - print( "\nscreen:expect{grid=[[") - print(kwargs.grid) - io.stdout:write( "]]"..attrstr) + local result = 'screen:expect{grid=[[\n' .. kwargs.grid .. '\n]]' .. attrstr for _, k in ipairs(ext_keys) do - if ext_state[k] ~= nil and not (k == "win_viewport" and not self.options.ext_multigrid) then - io.stdout:write(", "..k.."="..fmt_ext_state(k, ext_state[k])) + if ext_state[k] ~= nil and not (k == 'win_viewport' and not self.options.ext_multigrid) then + result = result .. ', ' .. k .. '=' .. fmt_ext_state(k, ext_state[k]) end end - print("}\n") + result = result .. '}' + + return result +end + +function Screen:print_snapshot(attrs, ignore) + print('\n' .. self:_print_snapshot(attrs, ignore) .. '\n') io.stdout:flush() end @@ -1422,7 +1683,7 @@ function Screen:_insert_hl_id(attr_state, hl_id) else info[1] = {} for k, v in pairs(raw_info[1]) do - if k ~= "id" then + if k ~= 'id' then info[1][k] = v end end @@ -1432,9 +1693,9 @@ function Screen:_insert_hl_id(attr_state, hl_id) local entry = self._attr_table[hl_id] local attrval if self._rgb_cterm then - attrval = {entry[1], entry[2], info} -- unpack() doesn't work + attrval = { entry[1], entry[2], info } -- unpack() doesn't work elseif self._options.ext_hlstate then - attrval = {entry[1], info} + attrval = { entry[1], info } else attrval = self._options.rgb and entry[1] or entry[2] end @@ -1450,17 +1711,17 @@ function Screen:linegrid_check_attrs(attrs) local iinfo = self._hl_info[i] local matchinfo = {} if #iinfo > 1 then - for k,item in ipairs(iinfo) do + for k, item in ipairs(iinfo) do matchinfo[k] = id_to_index[item.id] end else matchinfo = iinfo end - for k,v in pairs(attrs) do + for k, v in pairs(attrs) do local attr, info, attr_rgb, attr_cterm if self._rgb_cterm then attr_rgb, attr_cterm, info = unpack(v) - attr = {attr_rgb, attr_cterm} + attr = { attr_rgb, attr_cterm } info = info or {} elseif self._options.ext_hlstate then attr, info = unpack(v) @@ -1472,12 +1733,12 @@ function Screen:linegrid_check_attrs(attrs) if #info == #matchinfo then local match = false if #info == 1 then - if self:_equal_info(info[1],matchinfo[1]) then + if self:_equal_info(info[1], matchinfo[1]) then match = true end else match = true - for j = 1,#info do + for j = 1, #info do if info[j] ~= matchinfo[j] then match = false end @@ -1489,32 +1750,34 @@ function Screen:linegrid_check_attrs(attrs) end end end - if self:_equal_attr_def(self._rgb_cterm and {{}, {}} or {}, def_attr) and #self._hl_info[i] == 0 then - id_to_index[i] = "" + if + self:_equal_attr_def(self._rgb_cterm and { {}, {} } or {}, def_attr) + and #self._hl_info[i] == 0 + then + id_to_index[i] = '' end end return id_to_index end - function Screen:_pprint_hlitem(item) - -- print(inspect(item)) - local multi = self._rgb_cterm or self._options.ext_hlstate - local cterm = (not self._rgb_cterm and not self._options.rgb) - local attrdict = "{"..self:_pprint_attrs(multi and item[1] or item, cterm).."}" - local attrdict2, hlinfo - local descdict = "" - if self._rgb_cterm then - attrdict2 = ", {"..self:_pprint_attrs(item[2], true).."}" - hlinfo = item[3] - else - attrdict2 = "" - hlinfo = item[2] - end - if self._options.ext_hlstate then - descdict = ", {"..self:_pprint_hlinfo(hlinfo).."}" - end - return (multi and "{" or "")..attrdict..attrdict2..descdict..(multi and "}" or "") + -- print(inspect(item)) + local multi = self._rgb_cterm or self._options.ext_hlstate + local cterm = (not self._rgb_cterm and not self._options.rgb) + local attrdict = '{' .. self:_pprint_attrs(multi and item[1] or item, cterm) .. '}' + local attrdict2, hlinfo + local descdict = '' + if self._rgb_cterm then + attrdict2 = ', {' .. self:_pprint_attrs(item[2], true) .. '}' + hlinfo = item[3] + else + attrdict2 = '' + hlinfo = item[2] + end + if self._options.ext_hlstate then + descdict = ', {' .. self:_pprint_hlinfo(hlinfo) .. '}' + end + return (multi and '{' or '') .. attrdict .. attrdict2 .. descdict .. (multi and '}' or '') end function Screen:_pprint_hlinfo(states) @@ -1522,37 +1785,37 @@ function Screen:_pprint_hlinfo(states) local items = {} for f, v in pairs(states[1]) do local desc = tostring(v) - if type(v) == type("") then - desc = '"'..desc..'"' + if type(v) == type('') then + desc = '"' .. desc .. '"' end - table.insert(items, f.." = "..desc) + table.insert(items, f .. ' = ' .. desc) end - return "{"..table.concat(items, ", ").."}" + return '{' .. table.concat(items, ', ') .. '}' else - return table.concat(states, ", ") + return table.concat(states, ', ') end end - function Screen:_pprint_attrs(attrs, cterm) - local items = {} - for f, v in pairs(attrs) do - local desc = tostring(v) - if f == "foreground" or f == "background" or f == "special" then - if Screen.colornames[v] ~= nil then - desc = "Screen.colors."..Screen.colornames[v] - elseif cterm then - desc = tostring(v) - else - desc = string.format("tonumber('0x%06x')",v) - end + local items = {} + for f, v in pairs(attrs) do + local desc = tostring(v) + if f == 'foreground' or f == 'background' or f == 'special' then + if Screen.colornames[v] ~= nil then + desc = 'Screen.colors.' .. Screen.colornames[v] + elseif cterm then + desc = tostring(v) + else + desc = string.format("tonumber('0x%06x')", v) end - table.insert(items, f.." = "..desc) end - return table.concat(items, ", ") + table.insert(items, f .. ' = ' .. desc) + end + return table.concat(items, ', ') end -local function backward_find_meaningful(tbl, from) -- luacheck: no unused +---@diagnostic disable-next-line: unused-local, unused-function +local function backward_find_meaningful(tbl, from) -- luacheck: no unused for i = from or #tbl, 1, -1 do if tbl[i] ~= ' ' then return i + 1 @@ -1568,7 +1831,7 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id) if self._options.ext_linegrid then local id = attr_state.id_to_index[hl_id] - if id == "" then -- sentinel for empty it + if id == '' then -- sentinel for empty it return nil elseif id ~= nil then return id @@ -1579,7 +1842,7 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id) return id end local kind = self._options.rgb and 1 or 2 - return "UNEXPECTED "..self:_pprint_attrs(self._attr_table[hl_id][kind]) + return 'UNEXPECTED ' .. self:_pprint_attrs(self._attr_table[hl_id][kind]) else if self:_equal_attrs(attrs, {}) then -- ignore this attrs @@ -1587,49 +1850,57 @@ function Screen:_get_attr_id(attr_state, attrs, hl_id) end for id, a in pairs(attr_state.ids) do if self:_equal_attrs(a, attrs) then - return id - end + return id + end end if attr_state.mutable then table.insert(attr_state.ids, attrs) attr_state.modified = true return #attr_state.ids end - return "UNEXPECTED "..self:_pprint_attrs(attrs) + return 'UNEXPECTED ' .. self:_pprint_attrs(attrs) end end function Screen:_equal_attr_def(a, b) if self._rgb_cterm then - return self:_equal_attrs(a[1],b[1]) and self:_equal_attrs(a[2],b[2]) + return self:_equal_attrs(a[1], b[1]) and self:_equal_attrs(a[2], b[2]) elseif self._options.rgb then - return self:_equal_attrs(a,b[1]) + return self:_equal_attrs(a, b[1]) else - return self:_equal_attrs(a,b[2]) + return self:_equal_attrs(a, b[2]) end end function Screen:_equal_attrs(a, b) - return a.bold == b.bold and a.standout == b.standout and - a.underline == b.underline and a.undercurl == b.undercurl and - a.underdouble == b.underdouble and a.underdotted == b.underdotted and - a.underdashed == b.underdashed and a.italic == b.italic and - a.reverse == b.reverse and a.foreground == b.foreground and - a.background == b.background and a.special == b.special and a.blend == b.blend and - a.strikethrough == b.strikethrough and - a.fg_indexed == b.fg_indexed and a.bg_indexed == b.bg_indexed + return a.bold == b.bold + and a.standout == b.standout + and a.underline == b.underline + and a.undercurl == b.undercurl + and a.underdouble == b.underdouble + and a.underdotted == b.underdotted + and a.underdashed == b.underdashed + and a.italic == b.italic + and a.reverse == b.reverse + and a.foreground == b.foreground + and a.background == b.background + and a.special == b.special + and a.blend == b.blend + and a.strikethrough == b.strikethrough + and a.fg_indexed == b.fg_indexed + and a.bg_indexed == b.bg_indexed + and a.url == b.url end function Screen:_equal_info(a, b) - return a.kind == b.kind and a.hi_name == b.hi_name and - a.ui_name == b.ui_name + return a.kind == b.kind and a.hi_name == b.hi_name and a.ui_name == b.ui_name end function Screen:_attr_index(attrs, attr) if not attrs then return nil end - for i,a in pairs(attrs) do + for i, a in pairs(attrs) do if self:_equal_attrs(a, attr) then return i end diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua index 7cc1accd3f..42e2b4d4b5 100644 --- a/test/functional/ui/screen_basic_spec.lua +++ b/test/functional/ui/screen_basic_spec.lua @@ -4,39 +4,39 @@ local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.cl local feed, command = helpers.feed, helpers.command local insert = helpers.insert local eq = helpers.eq -local funcs, meths = helpers.funcs, helpers.meths +local fn, api = helpers.fn, helpers.api describe('screen', function() local screen - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + '-n', + '--cmd', + 'set shortmess+=I background=light noswapfile belloff= noshowcmd noruler', + '--cmd', + 'colorscheme vim', + '--embed', + } before_each(function() local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + }) end) it('default initial screen', function() - screen:expect([[ + screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) @@ -49,18 +49,23 @@ local function screen_tests(linegrid) before_each(function() clear() screen = Screen.new() - screen:attach({rgb=true,ext_linegrid=linegrid}) - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {bold=true, reverse=true}, - [2] = {bold=true}, - [3] = {reverse=true}, - [4] = {background = Screen.colors.LightGrey, underline = true}, - [5] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Fuchsia}, - [6] = {bold = true, foreground = Screen.colors.Fuchsia}, - [7] = {bold = true, foreground = Screen.colors.SeaGreen}, - [8] = {foreground = Screen.colors.White, background = Screen.colors.Red}, - } ) + screen:attach({ rgb = true, ext_linegrid = linegrid }) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { bold = true, reverse = true }, + [2] = { bold = true }, + [3] = { reverse = true }, + [4] = { background = Screen.colors.LightGrey, underline = true }, + [5] = { + background = Screen.colors.LightGrey, + underline = true, + bold = true, + foreground = Screen.colors.Fuchsia, + }, + [6] = { bold = true, foreground = Screen.colors.Fuchsia }, + [7] = { bold = true, foreground = Screen.colors.SeaGreen }, + [8] = { foreground = Screen.colors.White, background = Screen.colors.Red }, + }) end) describe('bell/visual bell', function() @@ -83,7 +88,7 @@ local function screen_tests(linegrid) describe(':set title', function() it('is forwarded to the UI', function() local expected = 'test-title' - command('set titlestring='..expected) + command('set titlestring=' .. expected) command('set title') screen:expect(function() eq(expected, screen.title) @@ -100,7 +105,7 @@ local function screen_tests(linegrid) describe(':set icon', function() it('is forwarded to the UI', function() local expected = 'test-icon' - command('set iconstring='..expected) + command('set iconstring=' .. expected) command('set icon') screen:expect(function() eq(expected, screen.icon) @@ -119,74 +124,46 @@ local function screen_tests(linegrid) command('set laststatus=2') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | ]]) feed('<c-l>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 {1:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } command('split') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) feed('<c-l>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | - ]], reset=true} + ]], + reset = true, + } end) end) @@ -196,17 +173,10 @@ local function screen_tests(linegrid) command('sp') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) @@ -217,17 +187,10 @@ local function screen_tests(linegrid) command('resize 8') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 {1:[No Name] }| | - {0:~ }| - {0:~ }| + {0:~ }|*2 {3:[No Name] }| | ]]) @@ -239,34 +202,20 @@ local function screen_tests(linegrid) command('vsp') screen:expect([[ ^ │ │ | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] }{3:[No Name] [No Name] }| | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] }| | ]]) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -282,17 +231,10 @@ local function screen_tests(linegrid) insert('hello') screen:expect([[ hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {3:[No Name] [+] }| | ]]) @@ -302,33 +244,17 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:4}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| hell^o2 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) command('tabprevious') screen:expect([[ {2: }{6:4}{2:+ [No Name] }{4: + [No Name] }{3: }{4:X}| hell^o │hello │hello | - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| - {0:~ }│{0:~ }│{0:~ }| + {0:~ }│{0:~ }│{0:~ }|*5 {1:[No Name] [+] }{3:[No Name] [+] [No Name] [+] }| hello | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {3:[No Name] [+] }| | ]]) @@ -339,34 +265,14 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - feed(':echo "'..string.rep('x\\n', 11)..'"<cr>') + feed(':echo "' .. string.rep('x\\n', 11) .. '"<cr>') screen:expect([[ {1: }| - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*11 | {7:Press ENTER or type command to continue}^ | ]]) @@ -375,34 +281,13 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - feed(':echo "'..string.rep('x\\n', 12)..'"<cr>') + feed(':echo "' .. string.rep('x\\n', 12) .. '"<cr>') screen:expect([[ - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | - x | + x |*12 | {7:Press ENTER or type command to continue}^ | ]]) @@ -411,20 +296,9 @@ local function screen_tests(linegrid) screen:expect([[ {4: [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) - end) it('redraws properly with :tab split right after scroll', function() @@ -433,17 +307,7 @@ local function screen_tests(linegrid) command('vsplit') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | - foo │foo | + foo │foo |*11 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -451,17 +315,8 @@ local function screen_tests(linegrid) feed('<PageDown>') screen:expect([[ ^foo │foo | - foo │foo | - foo │foo | - foo │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | - bar │foo | + foo │foo |*3 + bar │foo |*8 {1:[No Name] [+] }{3:[No Name] [+] }| | ]]) @@ -469,17 +324,8 @@ local function screen_tests(linegrid) screen:expect([[ {4: }{5:2}{4:+ [No Name] }{2: + [No Name] }{3: }{4:X}| ^foo | - foo | - foo | - foo | - bar | - bar | - bar | - bar | - bar | - bar | - bar | - bar | + foo |*3 + bar |*8 | ]]) end) @@ -491,17 +337,7 @@ local function screen_tests(linegrid) screen:expect([[ {2: + [No Name] }{4: [No Name] }{3: }{4:X}| hell^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) @@ -509,17 +345,7 @@ local function screen_tests(linegrid) screen:expect([[ {4: + [No Name] }{2: [No Name] }{3: }{4:X}| ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 | ]]) end) @@ -532,16 +358,7 @@ local function screen_tests(linegrid) line 1 | line 2 | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 {2:-- INSERT --} | ]]) end) @@ -557,17 +374,7 @@ local function screen_tests(linegrid) screen:expect([[ 0123^456 | 789 | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*11 1,5 All | ]]) end) @@ -578,18 +385,7 @@ local function screen_tests(linegrid) feed(':ls') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 :ls^ | ]]) end) @@ -598,15 +394,7 @@ local function screen_tests(linegrid) feed(':ls<cr>') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -783,9 +571,7 @@ local function screen_tests(linegrid) feed('iresize') screen:expect([[ resize^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {2:-- INSERT --} | ]]) end) @@ -811,38 +597,27 @@ local function screen_tests(linegrid) command([[autocmd VimResized * redrawtabline]]) command([[autocmd VimResized * lua vim.api.nvim_echo({ { 'Hello' } }, false, {})]]) command([[autocmd VimResized * let g:echospace = v:echospace]]) - meths.set_option_value('showtabline', 2, {}) + api.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) screen:try_resize(30, 6) screen:expect([[ {2: + [No Name] }{3: }| resiz^e | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) - eq(29, meths.get_var('echospace')) + eq(29, api.nvim_get_var('echospace')) end) it('messages from the same Ex command as resize are visible #22225', function() feed(':set columns=20 | call<CR>') screen:expect([[ - | - | - | - | - | - | - | - | - | + |*9 {1: }| {8:E471: Argument requi}| {8:red} | @@ -852,53 +627,25 @@ local function screen_tests(linegrid) feed('<CR>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) feed(':set columns=0<CR>') screen:expect([[ - | - | - | - | - | - {1: }| - {8:E594: Need a}| - {8:t least 12 c}| - {8:olumns: colu}| - {8:mns=0} | - {7:Press ENTER }| - {7:or type comm}| - {7:and to conti}| - {7:nue}^ | + | + {0:~ }|*7 + {1: }| + {8:E594: Need at least }| + {8:12 columns: columns=}| + {8:0} | + {7:Press ENTER or type }| + {7:command to continue}^ | ]]) feed('<CR>') screen:expect([[ - ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - | + ^ | + {0:~ }|*12 + | ]]) end) end) @@ -909,15 +656,7 @@ local function screen_tests(linegrid) feed(':ls<CR>') screen:expect([[ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 {1: }| :ls | 1 %a "[No Name]" line 1 | @@ -926,18 +665,7 @@ local function screen_tests(linegrid) feed('<F1>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 TEST | ]]) end) @@ -950,45 +678,23 @@ local function screen_tests(linegrid) feed('ifooj') screen:expect([[ foo^j | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 {2:-- INSERT --} | ]]) feed('k') screen:expect([[ fo^o | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) end) end -describe("Screen (char-based)", function() +describe('Screen (char-based)', function() screen_tests(false) end) -describe("Screen (line-based)", function() +describe('Screen (line-based)', function() screen_tests(true) end) @@ -997,41 +703,75 @@ describe('Screen default colors', function() local function startup(light, termcolors) local extra = (light and ' background=light') or '' - local nvim_argv = {helpers.nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', - '--cmd', 'set shortmess+=I noswapfile belloff= noshowcmd noruler'..extra, - '--embed'} + local nvim_argv = { + helpers.nvim_prog, + '-u', + 'NONE', + '-i', + 'NONE', + '-N', + '--cmd', + 'set shortmess+=I noswapfile belloff= noshowcmd noruler' .. extra, + '--cmd', + 'colorscheme vim', + '--embed', + } local screen_nvim = spawn(nvim_argv) set_session(screen_nvim) screen = Screen.new() - screen:attach(termcolors and {rgb=true,ext_termcolors=true} or {rgb=true}) + screen:attach(termcolors and { rgb = true, ext_termcolors = true } or { rgb = true }) end it('are dark per default', function() startup(false, false) - screen:expect{condition=function() - eq({rgb_bg=0, rgb_fg=Screen.colors.White, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = 0, + rgb_fg = Screen.colors.White, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be set to light', function() startup(true, false) - screen:expect{condition=function() - eq({rgb_fg=Screen.colors.White, rgb_bg=0, rgb_sp=Screen.colors.Red, - cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq({ + rgb_bg = Screen.colors.White, + rgb_fg = 0, + rgb_sp = Screen.colors.Red, + cterm_bg = 0, + cterm_fg = 0, + }, screen.default_colors) + end, + } end) it('can be handled by external terminal', function() startup(false, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } startup(true, true) - screen:expect{condition=function() - eq({rgb_bg=-1, rgb_fg=-1, rgb_sp=-1, cterm_bg=0, cterm_fg=0}, screen.default_colors) - end} + screen:expect { + condition = function() + eq( + { rgb_bg = -1, rgb_fg = -1, rgb_sp = -1, cterm_bg = 0, cterm_fg = 0 }, + screen.default_colors + ) + end, + } end) end) @@ -1039,46 +779,48 @@ it('CTRL-F or CTRL-B scrolls a page after UI attach/resize #20605', function() clear() local screen = Screen.new(100, 100) screen:attach() - eq(100, meths.get_option_value('lines', {})) - eq(99, meths.get_option_value('window', {})) - eq(99, meths.win_get_height(0)) + eq(100, api.nvim_get_option_value('lines', {})) + eq(99, api.nvim_get_option_value('window', {})) + eq(99, api.nvim_win_get_height(0)) feed('1000o<Esc>') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('<C-B>') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('<C-B>') - eq(709, funcs.line('w0')) + eq(709, fn.line('w0')) feed('<C-F>') - eq(806, funcs.line('w0')) + eq(806, fn.line('w0')) feed('<C-F>') - eq(903, funcs.line('w0')) + eq(903, fn.line('w0')) feed('G') screen:try_resize(50, 50) - eq(50, meths.get_option_value('lines', {})) - eq(49, meths.get_option_value('window', {})) - eq(49, meths.win_get_height(0)) - eq(953, funcs.line('w0')) + eq(50, api.nvim_get_option_value('lines', {})) + eq(49, api.nvim_get_option_value('window', {})) + eq(49, api.nvim_win_get_height(0)) + eq(953, fn.line('w0')) feed('<C-B>') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('<C-B>') - eq(859, funcs.line('w0')) + eq(859, fn.line('w0')) feed('<C-F>') - eq(906, funcs.line('w0')) + eq(906, fn.line('w0')) feed('<C-F>') - eq(953, funcs.line('w0')) + eq(953, fn.line('w0')) end) it("showcmd doesn't cause empty grid_line with redrawdebug=compositor #22593", function() clear() local screen = Screen.new(30, 2) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, + [0] = { bold = true, foreground = Screen.colors.Blue }, }) screen:attach() command('set showcmd redrawdebug=compositor') feed('d') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | d | - ]]} + ]], + } end) diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua index dc7ef666bd..a05436cf55 100644 --- a/test/functional/ui/searchhl_spec.lua +++ b/test/functional/ui/searchhl_spec.lua @@ -5,7 +5,7 @@ local command = helpers.command local feed_command = helpers.feed_command local eq = helpers.eq local eval = helpers.eval -local funcs = helpers.funcs +local fn = helpers.fn local testprg = helpers.testprg describe('search highlighting', function() @@ -15,46 +15,50 @@ describe('search highlighting', function() clear() screen = Screen.new(40, 7) screen:attach() - screen:set_default_attr_ids( { - [1] = {bold=true, foreground=Screen.colors.Blue}, - [2] = {background = Screen.colors.Yellow}, -- Search - [3] = {reverse = true}, - [4] = {foreground = Screen.colors.Red}, -- WarningMsg - [5] = {bold = true, reverse = true}, -- StatusLine - [6] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey}, -- Folded + screen:set_default_attr_ids({ + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { background = Screen.colors.Yellow }, -- Search + [3] = { reverse = true }, + [4] = { foreground = Screen.colors.Red }, -- WarningMsg + [5] = { bold = true, reverse = true }, -- StatusLine + [6] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGrey }, -- Folded }) end) it('is disabled by ":set nohlsearch"', function() feed_command('set nohlsearch') - insert("some text\nmore text") - feed("gg/text<cr>") + insert('some text\nmore text') + feed('gg/text<cr>') screen:expect([[ some ^text | more text | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 /text | ]]) end) it('is disabled in folded text', function() - insert("some text\nmore text") + insert('some text\nmore text') feed_command('1,2fold') - feed("gg/text") - screen:expect{grid=[[ + feed('gg/text') + screen:expect { + grid = [[ {6:+-- 2 lines: some text·················}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 /text^ | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 8, linecount = 2, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 3, + curline = 0, + curcol = 8, + linecount = 2, + sum_scroll_delta = 0, + }, + }, + } end) local function test_search_hl() @@ -66,7 +70,7 @@ describe('search highlighting', function() ]]) -- 'hlsearch' is enabled by default. #2859 - feed("gg/text<cr>") + feed('gg/text<cr>') screen:expect([[ some {2:^text} | more {2:text}stuff | @@ -78,7 +82,7 @@ describe('search highlighting', function() ]]) -- overlapping matches not allowed - feed("3nx") + feed('3nx') screen:expect([[ some {2:text} | more {2:text}stuff | @@ -89,7 +93,7 @@ describe('search highlighting', function() /text | ]]) - feed("ggn*") -- search for entire word + feed('ggn*') -- search for entire word screen:expect([[ some {2:text} | more textstuff | @@ -100,7 +104,7 @@ describe('search highlighting', function() /\<text\> | ]]) - feed_command("nohlsearch") + feed_command('nohlsearch') screen:expect([[ some text | more textstuff | @@ -119,7 +123,7 @@ describe('search highlighting', function() it("works when 'winhighlight' doesn't change Search highlight", function() command('setlocal winhl=NonText:Underlined') local attrs = screen:get_default_attr_ids() - attrs[1] = {foreground = Screen.colors.SlateBlue, underline = true} + attrs[1] = { foreground = Screen.colors.SlateBlue, underline = true } screen:set_default_attr_ids(attrs) test_search_hl() end) @@ -127,7 +131,7 @@ describe('search highlighting', function() it("works when 'winhighlight' changes Search highlight", function() command('setlocal winhl=Search:Underlined') local attrs = screen:get_default_attr_ids() - attrs[2] = {foreground = Screen.colors.SlateBlue, underline = true} + attrs[2] = { foreground = Screen.colors.SlateBlue, underline = true } screen:set_default_attr_ids(attrs) test_search_hl() end) @@ -135,9 +139,9 @@ describe('search highlighting', function() describe('CurSearch highlight', function() before_each(function() screen:set_default_attr_ids({ - [1] = {background = Screen.colors.Yellow}, -- Search - [2] = {foreground = Screen.colors.White, background = Screen.colors.Black}, -- CurSearch - [3] = {foreground = Screen.colors.Red}, -- WarningMsg + [1] = { background = Screen.colors.Yellow }, -- Search + [2] = { foreground = Screen.colors.White, background = Screen.colors.Black }, -- CurSearch + [3] = { foreground = Screen.colors.Red }, -- WarningMsg }) command('highlight CurSearch guibg=Black guifg=White') end) @@ -152,7 +156,8 @@ describe('search highlighting', function() humans think is impossible.]]) feed('/bee<CR>') - screen:expect{grid=[[ + screen:expect { + grid = [[ There is no way that a {2:^bee} should be | able to fly. Its wings are too small | to get its fat little body off the | @@ -160,10 +165,12 @@ describe('search highlighting', function() anyway because {1:bee}s don't care what | humans think is impossible. | {3:search hit BOTTOM, continuing at TOP} | - ]]} + ]], + } feed('nn') - screen:expect{grid=[[ + screen:expect { + grid = [[ There is no way that a {1:bee} should be | able to fly. Its wings are too small | to get its fat little body off the | @@ -171,10 +178,12 @@ describe('search highlighting', function() anyway because {2:^bee}s don't care what | humans think is impossible. | /bee | - ]]} + ]], + } feed('N') - screen:expect{grid=[[ + screen:expect { + grid = [[ There is no way that a {1:bee} should be | able to fly. Its wings are too small | to get its fat little body off the | @@ -182,7 +191,8 @@ describe('search highlighting', function() anyway because {1:bee}s don't care what | humans think is impossible. | ?bee | - ]]} + ]], + } end) it('works for multiline match', function() @@ -273,54 +283,42 @@ describe('search highlighting', function() end) it('highlights after EOL', function() - insert("\n\n\n\n\n\n") + insert('\n\n\n\n\n\n') - feed("gg/^<cr>") + feed('gg/^<cr>') screen:expect([[ {2: } | {2:^ } | - {2: } | - {2: } | - {2: } | - {2: } | + {2: } |*4 /^ | ]]) -- Test that highlights are preserved after moving the cursor. - feed("j") + feed('j') screen:expect([[ - {2: } | - {2: } | + {2: } |*2 {2:^ } | - {2: } | - {2: } | - {2: } | + {2: } |*3 /^ | ]]) -- Repeat the test in rightleft mode. - command("nohlsearch") - command("set rightleft") - feed("gg/^<cr>") + command('nohlsearch') + command('set rightleft') + feed('gg/^<cr>') screen:expect([[ {2: }| {2:^ }| - {2: }| - {2: }| - {2: }| - {2: }| + {2: }|*4 ^/ | ]]) - feed("j") + feed('j') screen:expect([[ - {2: }| - {2: }| + {2: }|*2 {2:^ }| - {2: }| - {2: }| - {2: }| + {2: }|*3 ^/ | ]]) end) @@ -338,7 +336,7 @@ describe('search highlighting', function() :file term | ]]) - feed('G') -- Follow :terminal output. + feed('G') -- Follow :terminal output. feed(':vnew<CR>') insert([[ foo bar baz @@ -349,8 +347,7 @@ describe('search highlighting', function() {3:foo} bar baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| bar baz {2:foo} │{MATCH:%d+}: {2:foo}{MATCH:%s+}| bar {2:foo} baz │{MATCH:%d+}: {2:foo}{MATCH:%s+}| - {1:~ }│{MATCH:.*}| - {1:~ }│{MATCH:.*}| + {1:~ }│{MATCH:.*}|*2 {5:[No Name] [+] }{3:term }| /foo^ | ]]) @@ -364,82 +361,61 @@ describe('search highlighting', function() the first line in a little file]]) command('vsplit') - feed("gg/li") + feed('gg/li') screen:expect([[ the first {3:li}ne │the first {2:li}ne | in a {2:li}ttle file │in a {2:li}ttle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /li^ | ]]) -- check that consecutive matches are caught by C-g/C-t - feed("<C-g>") + feed('<C-g>') screen:expect([[ the first {2:li}ne │the first {2:li}ne | in a {3:li}ttle file │in a {2:li}ttle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /li^ | ]]) - feed("<C-t>") + feed('<C-t>') screen:expect([[ the first {3:li}ne │the first {2:li}ne | in a {2:li}ttle file │in a {2:li}ttle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /li^ | ]]) - feed("t") + feed('t') screen:expect([[ the first line │the first line | in a {3:lit}tle file │in a {2:lit}tle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /lit^ | ]]) - feed("<cr>") + feed('<cr>') screen:expect([[ the first line │the first line | in a {2:^lit}tle file │in a {2:lit}tle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /lit | ]]) - feed("/fir") + feed('/fir') screen:expect([[ the {3:fir}st line │the {2:fir}st line | in a little file │in a little file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /fir^ | ]]) -- incsearch have priority over hlsearch - feed("<esc>/ttle") + feed('<esc>/ttle') screen:expect([[ the first line │the first line | in a li{3:ttle} file │in a li{2:ttle} file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /ttle^ | ]]) @@ -448,10 +424,7 @@ describe('search highlighting', function() screen:expect([[ the first line │the first line | in a {2:^lit}tle file │in a {2:lit}tle file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 | ]]) eq('lit', eval('@/')) @@ -461,10 +434,7 @@ describe('search highlighting', function() screen:expect([[ the first line │the first line | in a ^little file │in a little file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 :noh | ]]) @@ -472,20 +442,14 @@ describe('search highlighting', function() screen:expect([[ the {3:first} line │the {2:first} line | in a little file │in a little file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /first^ | ]]) feed('<esc>') screen:expect([[ the first line │the first line | in a ^little file │in a little file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 | ]]) @@ -494,43 +458,34 @@ describe('search highlighting', function() command([[let @/ = 'i']]) -- moves to next match of previous search pattern, just like /<cr> feed('/<c-g><cr>') - eq({0, 1, 6, 0}, funcs.getpos('.')) + eq({ 0, 1, 6, 0 }, fn.getpos('.')) -- moves to next match of previous search pattern, just like /<cr> feed('/<cr>') - eq({0, 1, 12, 0}, funcs.getpos('.')) + eq({ 0, 1, 12, 0 }, fn.getpos('.')) -- moves to next match of previous search pattern, just like /<cr> feed('/<c-t><cr>') - eq({0, 2, 1, 0}, funcs.getpos('.')) + eq({ 0, 2, 1, 0 }, fn.getpos('.')) -- 8.0.1304, test that C-g and C-t works with incsearch and empty pattern feed('<esc>/fi<CR>') screen:expect([[ the {2:fi}rst line │the {2:fi}rst line | in a little {2:^fi}le │in a little {2:fi}le | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /fi | ]]) feed('//') screen:expect([[ the {3:fi}rst line │the {2:fi}rst line | in a little {2:fi}le │in a little {2:fi}le | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 //^ | ]]) feed('<C-g>') screen:expect([[ the {2:fi}rst line │the {2:fi}rst line | in a little {3:fi}le │in a little {2:fi}le | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 //^ | ]]) feed('<Esc>') @@ -541,10 +496,7 @@ describe('search highlighting', function() screen:expect([[ the first line │the first line | in a little {3:file} │in a little {2:file} | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /file^ | ]]) feed('<Esc>') @@ -557,10 +509,7 @@ describe('search highlighting', function() screen:expect([[ the {3:first} line │the {2:first} line | in a little file │in a little file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /first^ | ]]) feed('<Esc>') @@ -570,10 +519,7 @@ describe('search highlighting', function() screen:expect([[ the first line │the first line | in a {3:little} file │in a {2:little} file | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 /little^ | ]]) feed('<Esc>') @@ -586,37 +532,28 @@ describe('search highlighting', function() not the match you're looking for the match is here]]) - feed("gg/mat/e") + feed('gg/mat/e') screen:expect([[ not the {3:mat}ch you're looking for | the {2:mat}ch is here | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 /mat/e^ | ]]) -- Search with count and /e offset fixed in Vim patch 7.4.532. - feed("<esc>2/mat/e") + feed('<esc>2/mat/e') screen:expect([[ not the {2:mat}ch you're looking for | the {3:mat}ch is here | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 /mat/e^ | ]]) - feed("<cr>") + feed('<cr>') screen:expect([[ not the {2:mat}ch you're looking for | the {2:ma^t}ch is here | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 /mat/e | ]]) end) @@ -628,8 +565,7 @@ describe('search highlighting', function() screen:expect([[ | a repeated {2:^line } | - {2:a} repeated {2:line } | - {2:a} repeated {2:line } | + {2:a} repeated {2:line } |*2 {2:a} repeated line | {1:~ }| {4:search hit BOTTOM, continuing at TOP} | @@ -650,83 +586,80 @@ describe('search highlighting', function() it('works with matchadd and syntax', function() screen:set_default_attr_ids { - [1] = {bold=true, foreground=Screen.colors.Blue}; - [2] = {background = Screen.colors.Yellow}; - [3] = {reverse = true}; - [4] = {foreground = Screen.colors.Red}; - [5] = {bold = true, background = Screen.colors.Green}; - [6] = {italic = true, background = Screen.colors.Magenta}; - [7] = {bold = true, background = Screen.colors.Yellow}; - [8] = {foreground = Screen.colors.Blue4, background = Screen.colors.LightGray}; + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { background = Screen.colors.Yellow }, + [3] = { reverse = true }, + [4] = { foreground = Screen.colors.Red }, + [5] = { bold = true, background = Screen.colors.Green }, + [6] = { italic = true, background = Screen.colors.Magenta }, + [7] = { bold = true, background = Screen.colors.Yellow }, + [8] = { foreground = Screen.colors.Blue4, background = Screen.colors.LightGray }, } feed_command('set hlsearch') insert [[ very special text ]] - feed_command("syntax on") - feed_command("highlight MyGroup guibg=Green gui=bold") - feed_command("highlight MyGroup2 guibg=Magenta gui=italic") + feed_command('syntax on') + feed_command('highlight MyGroup guibg=Green gui=bold') + feed_command('highlight MyGroup2 guibg=Magenta gui=italic') feed_command("call matchadd('MyGroup', 'special')") feed_command("call matchadd('MyGroup2', 'text', 0)") -- searchhl and matchadd matches are exclusive, only the highest priority -- is used (and matches with lower priorities are not combined) - feed_command("/ial te") - screen:expect{grid=[[ + feed_command('/ial te') + screen:expect { + grid = [[ very {5:spec^ial}{2: te}{6:xt} | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {4:search hit BOTTOM, continuing at TOP} | - ]], win_viewport={ - [2] = {win = {id = 1000}, topline = 0, botline = 3, curline = 0, curcol = 11, linecount = 2, sum_scroll_delta = 0}; - }} + ]], + win_viewport = { + [2] = { + win = 1000, + topline = 0, + botline = 3, + curline = 0, + curcol = 11, + linecount = 2, + sum_scroll_delta = 0, + }, + }, + } -- check highlights work also in folds - feed("zf4j") - screen:expect{grid=[[ + feed('zf4j') + screen:expect { + grid = [[ {8:^+-- 2 lines: very special text·········}| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 {4:search hit BOTTOM, continuing at TOP} | - ]]} - command("%foldopen") + ]], + } + command('%foldopen') screen:expect([[ very {5:spec^ial}{2: te}{6:xt} | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 {4:search hit BOTTOM, continuing at TOP} | ]]) - feed_command("call clearmatches()") + feed_command('call clearmatches()') screen:expect([[ very spec{2:^ial te}xt | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :call clearmatches() | ]]) -- searchhl has priority over syntax, but in this case -- nonconflicting attributes are combined - feed_command("syntax keyword MyGroup special") + feed_command('syntax keyword MyGroup special') screen:expect([[ very {5:spec}{7:^ial}{2: te}xt | | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*4 :syntax keyword MyGroup special | ]]) end) @@ -737,13 +670,8 @@ describe('search highlighting', function() feed(':%g@a/b') screen:expect([[ {3:a/b}/c | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 :%g@a/b^ | ]]) end) end) - diff --git a/test/functional/ui/sign_spec.lua b/test/functional/ui/sign_spec.lua index b12e79bd42..847a918dc9 100644 --- a/test/functional/ui/sign_spec.lua +++ b/test/functional/ui/sign_spec.lua @@ -1,8 +1,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') -local clear, feed, command = helpers.clear, helpers.feed, helpers.command -local source = helpers.source -local meths = helpers.meths +local api, clear, eq = helpers.api, helpers.clear, helpers.eq +local eval, exec, feed = helpers.eval, helpers.exec, helpers.feed describe('Signs', function() local screen @@ -11,90 +10,68 @@ describe('Signs', function() clear() screen = Screen.new() screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=255}, - [1] = {background = Screen.colors.Yellow}, - [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey}, - [3] = {background = Screen.colors.Gray90}, - [4] = {bold = true, reverse = true}, - [5] = {reverse = true}, - [6] = {foreground = Screen.colors.Brown}, - [7] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, - [8] = {foreground = Screen.colors.Grey100, background = Screen.colors.Red}, - [9] = {bold = true, foreground = Screen.colors.Magenta}, - [10] = {foreground = Screen.colors.Blue1}, - [11] = {bold = true, foreground = Screen.colors.SeaGreen4}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = 255 }, + [1] = { background = Screen.colors.Yellow }, + [2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.Grey }, + [3] = { background = Screen.colors.Gray90 }, + [4] = { bold = true, reverse = true }, + [5] = { reverse = true }, + [6] = { foreground = Screen.colors.Brown }, + [7] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, + [8] = { foreground = Screen.colors.Grey100, background = Screen.colors.Red }, + [9] = { bold = true, foreground = Screen.colors.Magenta }, + [10] = { foreground = Screen.colors.Blue1 }, + [11] = { bold = true, foreground = Screen.colors.SeaGreen4 }, + }) end) describe(':sign place', function() it('allows signs with combining characters', function() feed('ia<cr>b<cr><esc>') - command('sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search') - command('sign define piet2 text=𠜎̀́̂̃̄̅ texthl=Search') - command('sign place 1 line=1 name=piet1 buffer=1') - command('sign place 2 line=2 name=piet2 buffer=1') + exec([[ + sign define piet1 text=𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄ texthl=Search + sign define piet2 text=𠜎̀́̂̃̄̅ texthl=Search + sign place 1 line=1 name=piet1 buffer=1 + sign place 2 line=2 name=piet2 buffer=1 + ]]) screen:expect([[ {1:𐌢̀́̂̃̅̄𐌢̀́̂̃̅̄}a | {1:𠜎̀́̂̃̄̅}b | {2: }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) end) it('shadows previously placed signs', function() feed('ia<cr>b<cr>c<cr><esc>') - command('sign define piet text=>> texthl=Search') - command('sign define pietx text=>! texthl=Search') - command('sign place 1 line=1 name=piet buffer=1') - command('sign place 2 line=3 name=piet buffer=1') - command('sign place 3 line=1 name=pietx buffer=1') + exec([[ + sign define piet text=>> texthl=Search + sign define pietx text=>! texthl=Search + sign place 1 line=1 name=piet buffer=1 + sign place 2 line=3 name=piet buffer=1 + sign place 3 line=1 name=pietx buffer=1 + ]]) screen:expect([[ {1:>!}a | {2: }b | {1:>>}c | {2: }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) end) it('allows signs with no text', function() feed('ia<cr>b<cr><esc>') - command('sign define piet1 text= texthl=Search') - command('sign place 1 line=1 name=piet1 buffer=1') + exec('sign define piet1 text= texthl=Search') + exec('sign place 1 line=1 name=piet1 buffer=1') screen:expect([[ a | b | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) end) @@ -104,7 +81,7 @@ describe('Signs', function() -- This used to cause a crash due to :sign using a special redraw -- (not updating nvim's specific highlight data structures) -- without proper redraw first, as split just flags for redraw later. - source([[ + exec([[ set cursorline sign define piet text=>> texthl=Search split @@ -115,8 +92,7 @@ describe('Signs', function() {1:>>}b | {2: }c | {2: } | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:[No Name] [+] }| {2: }{3:a }| {1:>>}b | @@ -130,58 +106,45 @@ describe('Signs', function() it('can combine text, linehl and numhl', function() feed('ia<cr>b<cr>c<cr><esc>') - command('set number') - command('sign define piet text=>> texthl=Search') - command('sign define pietx linehl=ErrorMsg') - command('sign define pietxx numhl=Folded') - command('sign place 1 line=1 name=piet buffer=1') - command('sign place 2 line=2 name=pietx buffer=1') - command('sign place 3 line=3 name=pietxx buffer=1') - command('sign place 4 line=4 name=piet buffer=1') - command('sign place 5 line=4 name=pietx buffer=1') - command('sign place 6 line=4 name=pietxx buffer=1') + exec([[ + set number + sign define piet text=>> texthl=Search + sign define pietx linehl=ErrorMsg + sign define pietxx numhl=Folded + sign place 1 line=1 name=piet buffer=1 + sign place 2 line=2 name=pietx buffer=1 + sign place 3 line=3 name=pietxx buffer=1 + sign place 4 line=4 name=piet buffer=1 + sign place 5 line=4 name=pietx buffer=1 + sign place 6 line=4 name=pietxx buffer=1 + ]]) screen:expect([[ {1:>>}{6: 1 }a | {2: }{6: 2 }{8:b }| {2: }{7: 3 }c | {1:>>}{7: 4 }{8:^ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- Check that 'statuscolumn' correctly applies numhl - command('set statuscolumn=%s%=%l\\ ') + exec('set statuscolumn=%s%=%l\\ ') screen:expect_unchanged() end) it('highlights the cursorline sign with culhl', function() feed('ia<cr>b<cr>c<esc>') - command('sign define piet text=>> texthl=Search culhl=ErrorMsg') - command('sign place 1 line=1 name=piet buffer=1') - command('sign place 2 line=2 name=piet buffer=1') - command('sign place 3 line=3 name=piet buffer=1') - command('set cursorline') + exec([[ + sign define piet text=>> texthl=Search culhl=ErrorMsg + sign place 1 line=1 name=piet buffer=1 + sign place 2 line=2 name=piet buffer=1 + sign place 3 line=3 name=piet buffer=1 + set cursorline + ]]) screen:expect([[ {1:>>}a | {1:>>}b | {8:>>}{3:^c }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) feed('k') @@ -189,411 +152,304 @@ describe('Signs', function() {1:>>}a | {8:>>}{3:^b }| {1:>>}c | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) - command('set nocursorline') + exec('set nocursorline') screen:expect([[ {1:>>}a | {1:>>}^b | {1:>>}c | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) - command('set cursorline cursorlineopt=line') + exec('set cursorline cursorlineopt=line') screen:expect([[ {1:>>}a | {1:>>}{3:^b }| {1:>>}c | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*10 | ]]) - command('set cursorlineopt=number') - command('hi! link SignColumn IncSearch') + exec('set cursorlineopt=number') + exec('hi! link SignColumn IncSearch') feed('Go<esc>2G') screen:expect([[ {1:>>}a | {8:>>}^b | {1:>>}c | {5: } | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- Check that 'statuscolumn' cursorline/signcolumn highlights are the same (#21726) - command('set statuscolumn=%s') + exec('set statuscolumn=%s') screen:expect_unchanged() end) it('multiple signs #9295', function() feed('ia<cr>b<cr>c<cr><esc>') - command('set number') - command('set signcolumn=yes:2') - command('sign define pietSearch text=>> texthl=Search') - command('sign define pietError text=XX texthl=Error') - command('sign define pietWarn text=WW texthl=Warning') - command('sign place 1 line=1 name=pietSearch buffer=1') - command('sign place 2 line=1 name=pietError buffer=1') - -- Line 2 helps checking that signs in the same line are ordered by Id. - command('sign place 4 line=2 name=pietSearch buffer=1') - command('sign place 3 line=2 name=pietError buffer=1') + exec([[ + set number + set signcolumn=yes:2 + sign define pietSearch text=>> texthl=Search + sign define pietError text=XX texthl=Error + sign define pietWarn text=WW texthl=Warning + sign place 6 line=3 name=pietSearch buffer=1 + sign place 7 line=3 name=pietWarn buffer=1 + sign place 5 line=3 name=pietError buffer=1 + ]]) -- Line 3 checks that with a limit over the maximum number -- of signs, the ones with the highest Ids are being picked, -- and presented by their sorted Id order. - command('sign place 6 line=3 name=pietSearch buffer=1') - command('sign place 7 line=3 name=pietWarn buffer=1') - command('sign place 5 line=3 name=pietError buffer=1') + screen:expect([[ + {2: }{6: 1 }a | + {2: }{6: 2 }b | + {1:>>}WW{6: 3 }c | + {2: }{6: 4 }^ | + {0:~ }|*9 + | + ]]) + exec([[ + sign place 1 line=1 name=pietSearch buffer=1 + sign place 2 line=1 name=pietError buffer=1 + " Line 2 helps checking that signs in the same line are ordered by Id. + sign place 4 line=2 name=pietSearch buffer=1 + sign place 3 line=2 name=pietError buffer=1 + ]]) screen:expect([[ {1:>>}{8:XX}{6: 1 }a | {8:XX}{1:>>}{6: 2 }b | {1:>>}WW{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- With the default setting, we get the sign with the top id. - command('set signcolumn=yes:1') + exec('set signcolumn=yes:1') screen:expect([[ {8:XX}{6: 1 }a | {1:>>}{6: 2 }b | WW{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- "auto:3" accommodates all the signs we defined so far. - command('set signcolumn=auto:3') - screen:expect([[ + exec('set signcolumn=auto:3') + local s3 = [[ {1:>>}{8:XX}{2: }{6: 1 }a | {8:XX}{1:>>}{2: }{6: 2 }b | {8:XX}{1:>>}WW{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | - ]]) + ]] + screen:expect(s3) -- Check "yes:9". - command('set signcolumn=yes:9') + exec('set signcolumn=yes:9') screen:expect([[ {1:>>}{8:XX}{2: }{6: 1 }a | {8:XX}{1:>>}{2: }{6: 2 }b | {8:XX}{1:>>}WW{2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- Check "auto:N" larger than the maximum number of signs defined in -- a single line (same result as "auto:3"). - command('set signcolumn=auto:4') - screen:expect{grid=[[ - {1:>>}{8:XX}{2: }{6: 1 }a | - {8:XX}{1:>>}{2: }{6: 2 }b | - {8:XX}{1:>>}WW{6: 3 }c | - {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - | - ]]} + exec('set signcolumn=auto:4') + screen:expect(s3) -- line deletion deletes signs. - command('2d') + exec('3move1') + exec('2d') screen:expect([[ - {1:>>}{8:XX}{2: }{6: 1 }a | - {8:XX}{1:>>}WW{6: 2 }^c | - {2: }{6: 3 } | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {1:>>}{8:XX}{6: 1 }a | + {8:XX}{1:>>}{6: 2 }^b | + {2: }{6: 3 } | + {0:~ }|*10 + | + ]]) + -- character deletion does not delete signs. + feed('x') + screen:expect([[ + {1:>>}{8:XX}{6: 1 }a | + {8:XX}{1:>>}{6: 2 }^ | + {2: }{6: 3 } | + {0:~ }|*10 | ]]) end) it('auto-resize sign column with minimum size (#13783)', function() feed('ia<cr>b<cr>c<cr><esc>') - command('set number') + exec('set number') -- sign column should always accommodate at the minimum size - command('set signcolumn=auto:1-3') + exec('set signcolumn=auto:1-3') screen:expect([[ {2: }{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- should support up to 8 signs at minimum - command('set signcolumn=auto:8-9') + exec('set signcolumn=auto:8-9') screen:expect([[ {2: }{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- should keep the same sign size when signs are not exceeding -- the minimum - command('set signcolumn=auto:2-5') - command('sign define pietSearch text=>> texthl=Search') - command('sign place 1 line=1 name=pietSearch buffer=1') + exec('set signcolumn=auto:2-5') + exec('sign define pietSearch text=>> texthl=Search') + exec('sign place 1 line=1 name=pietSearch buffer=1') screen:expect([[ {1:>>}{2: }{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- should resize itself when signs are exceeding minimum but -- not over the maximum - command('sign place 2 line=1 name=pietSearch buffer=1') - command('sign place 3 line=1 name=pietSearch buffer=1') - command('sign place 4 line=1 name=pietSearch buffer=1') + exec([[ + sign place 2 line=1 name=pietSearch buffer=1 + sign place 3 line=1 name=pietSearch buffer=1 + sign place 4 line=1 name=pietSearch buffer=1 + ]]) screen:expect([[ {1:>>>>>>>>}{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- should not increase size because sign with existing id is moved - command('sign place 4 line=1 name=pietSearch buffer=1') + exec('sign place 4 line=1 name=pietSearch buffer=1') screen:expect_unchanged() - command('sign unplace 4') + exec('sign unplace 4') screen:expect([[ {1:>>>>>>}{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) - command('sign place 4 line=1 name=pietSearch buffer=1') + exec('sign place 4 line=1 name=pietSearch buffer=1') -- should keep the column at maximum size when signs are -- exceeding the maximum - command('sign place 5 line=1 name=pietSearch buffer=1') - command('sign place 6 line=1 name=pietSearch buffer=1') - command('sign place 7 line=1 name=pietSearch buffer=1') - command('sign place 8 line=1 name=pietSearch buffer=1') + exec([[ + sign place 5 line=1 name=pietSearch buffer=1 + sign place 6 line=1 name=pietSearch buffer=1 + sign place 7 line=1 name=pietSearch buffer=1 + sign place 8 line=1 name=pietSearch buffer=1 + ]]) screen:expect([[ {1:>>>>>>>>>>}{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) end) it('ignores signs with no icon and text when calculating the signcolumn width', function() feed('ia<cr>b<cr>c<cr><esc>') - command('set number') - command('set signcolumn=auto:2') - command('sign define pietSearch text=>> texthl=Search') - command('sign define pietError text= texthl=Error') - command('sign place 2 line=1 name=pietError buffer=1') + exec([[ + set number + set signcolumn=auto:2 + sign define pietSearch text=>> texthl=Search + sign define pietError text= texthl=Error + sign place 2 line=1 name=pietError buffer=1 + ]]) -- no signcolumn with only empty sign screen:expect([[ {6: 1 }a | {6: 2 }b | {6: 3 }c | {6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) -- single column with 1 sign with text and one sign without - command('sign place 1 line=1 name=pietSearch buffer=1') + exec('sign place 1 line=1 name=pietSearch buffer=1') screen:expect([[ {1:>>}{6: 1 }a | {2: }{6: 2 }b | {2: }{6: 3 }c | {2: }{6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) end) - it('shows the line number when signcolumn=number but no marks on a line have text', function() + it('signcolumn=number', function() feed('ia<cr>b<cr>c<cr><esc>') - command('set number signcolumn=number') - command('sign define pietSearch text=>> texthl=Search numhl=Error') - command('sign define pietError text= texthl=Search numhl=Error') - command('sign place 1 line=1 name=pietSearch buffer=1') - command('sign place 2 line=2 name=pietError buffer=1') + exec([[ + set number signcolumn=number + sign define pietSearch text=>> texthl=Search numhl=Error + sign define pietError text= texthl=Search numhl=Error + sign place 1 line=1 name=pietSearch buffer=1 + sign place 2 line=2 name=pietError buffer=1 + ]]) + -- line number should be drawn if sign has no text -- no signcolumn, line number for "a" is Search, for "b" is Error, for "c" is LineNr screen:expect([[ {1: >> }a | {8: 2 }b | {6: 3 }c | {6: 4 }^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 + | + ]]) + -- number column on wrapped part of a line should be empty + feed('gg100aa<Esc>') + screen:expect([[ + {1: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {8: }aa^a | + {8: 2 }b | + {6: 3 }c | + {6: 4 } | + {0:~ }|*7 + | + ]]) + api.nvim_buf_set_extmark(0, api.nvim_create_namespace('test'), 0, 0, { + virt_lines = { { { 'VIRT LINES' } } }, + virt_lines_above = true, + }) + feed('<C-Y>') + -- number column on virtual lines should be empty + screen:expect([[ + {6: }VIRT LINES | + {1: >> }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {8: }aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {8: }aa^a | + {8: 2 }b | + {6: 3 }c | + {6: 4 } | + {0:~ }|*6 | ]]) end) it('can have 32bit sign IDs', function() - command('sign define piet text=>> texthl=Search') - command('sign place 100000 line=1 name=piet buffer=1') + exec('sign define piet text=>> texthl=Search') + exec('sign place 100000 line=1 name=piet buffer=1') feed(':sign place<cr>') screen:expect([[ {1:>>} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 {4: }| :sign place | {9:--- Signs ---} | @@ -606,72 +462,45 @@ describe('Signs', function() feed('<cr>') screen:expect([[ {1:>>}^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*12 | ]]) end) end) it('signcolumn width is updated when removing all signs after deleting lines', function() - meths.buf_set_lines(0, 0, 1, true, {'a', 'b', 'c', 'd', 'e'}) - command('sign define piet text=>>') - command('sign place 10001 line=1 name=piet') - command('sign place 10002 line=5 name=piet') - command('2delete') - command('sign unplace 10001') + api.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) + exec('sign define piet text=>>') + exec('sign place 10001 line=1 name=piet') + exec('sign place 10002 line=5 name=piet') + exec('2delete') + exec('sign unplace 10001') screen:expect([[ {2: }a | {2: }^c | {2: }d | >>e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) - command('sign unplace 10002') + exec('sign unplace 10002') screen:expect([[ a | ^c | d | e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*9 | ]]) end) it('signcolumn width is updated when removing all signs after inserting lines', function() - meths.buf_set_lines(0, 0, 1, true, {'a', 'b', 'c', 'd', 'e'}) - command('sign define piet text=>>') - command('sign place 10001 line=1 name=piet') - command('sign place 10002 line=5 name=piet') - command('copy .') - command('sign unplace 10001') + api.nvim_buf_set_lines(0, 0, 1, true, { 'a', 'b', 'c', 'd', 'e' }) + exec('sign define piet text=>>') + exec('sign place 10001 line=1 name=piet') + exec('sign place 10002 line=5 name=piet') + exec('copy .') + exec('sign unplace 10001') screen:expect([[ {2: }a | {2: }^a | @@ -679,16 +508,10 @@ describe('Signs', function() {2: }c | {2: }d | >>e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 | ]]) - command('sign unplace 10002') + exec('sign unplace 10002') screen:expect([[ a | ^a | @@ -696,20 +519,14 @@ describe('Signs', function() c | d | e | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 | ]]) end) it('numhl highlight is applied when signcolumn=no', function() screen:try_resize(screen._width, 4) - command([[ + exec([[ set nu scl=no call setline(1, ['line1', 'line2', 'line3']) call nvim_buf_set_extmark(0, nvim_create_namespace('test'), 0, 0, {'number_hl_group':'Error'}) @@ -723,4 +540,39 @@ describe('Signs', function() | ]]) end) + + it('no negative b_signcols.count with undo after initializing', function() + exec([[ + set signcolumn=auto:2 + call setline(1, 'a') + call nvim_buf_set_extmark(0, nvim_create_namespace(''), 0, 0, {'sign_text':'S1'}) + delete | redraw | undo + ]]) + end) + + it('sign not shown on line it was previously on after undo', function() + exec([[ + call setline(1, range(1, 4)) + call nvim_buf_set_extmark(0, nvim_create_namespace(''), 1, 0, {'sign_text':'S1'}) + ]]) + exec('norm 2Gdd') + exec('silent undo') + screen:expect([[ + {2: }1 | + S1^2 | + {2: }3 | + {2: }4 | + {0:~ }|*9 + | + ]]) + end) + + it('sign_undefine() frees all signs', function() + exec([[ + sign define 1 text=1 + sign define 2 text=2 + call sign_undefine() + ]]) + eq({}, eval('sign_getdefined()')) + end) end) diff --git a/test/functional/ui/spell_spec.lua b/test/functional/ui/spell_spec.lua index d18e19e5b2..8b5644ee42 100644 --- a/test/functional/ui/spell_spec.lua +++ b/test/functional/ui/spell_spec.lua @@ -6,8 +6,7 @@ local clear = helpers.clear local exec = helpers.exec local feed = helpers.feed local insert = helpers.insert -local meths = helpers.meths -local curbufmeths = helpers.curbufmeths +local api = helpers.api local is_os = helpers.is_os describe("'spell'", function() @@ -17,23 +16,26 @@ describe("'spell'", function() clear() screen = Screen.new(80, 8) screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {special = Screen.colors.Red, undercurl = true}, - [2] = {special = Screen.colors.Blue, undercurl = true}, - [3] = {foreground = tonumber('0x6a0dad')}, - [4] = {foreground = Screen.colors.Magenta}, - [5] = {bold = true, foreground = Screen.colors.SeaGreen}, - [6] = {foreground = Screen.colors.Red}, - [7] = {foreground = Screen.colors.Blue}, - [8] = {foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true}, - [9] = {bold = true}, - [10] = {background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue}, + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { special = Screen.colors.Red, undercurl = true }, + [2] = { special = Screen.colors.Blue, undercurl = true }, + [3] = { foreground = tonumber('0x6a0dad') }, + [4] = { foreground = Screen.colors.Magenta }, + [5] = { bold = true, foreground = Screen.colors.SeaGreen }, + [6] = { foreground = Screen.colors.Red }, + [7] = { foreground = Screen.colors.Blue }, + [8] = { foreground = Screen.colors.Blue, special = Screen.colors.Red, undercurl = true }, + [9] = { bold = true }, + [10] = { background = Screen.colors.LightGrey, foreground = Screen.colors.DarkBlue }, }) end) it('joins long lines #7937', function() - if is_os('openbsd') then pending('FIXME #12104', function() end) return end + if is_os('openbsd') then + pending('FIXME #12104', function() end) + return + end exec('set spell') insert([[ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod @@ -54,7 +56,6 @@ describe("'spell'", function() {0:~ }| | ]]) - end) -- oldtest: Test_spell_screendump() @@ -125,8 +126,7 @@ describe("'spell'", function() Not | and her^e | and here. | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) -- Undo also updates the next line (go to command line to remove message) @@ -137,8 +137,7 @@ describe("'spell'", function() Not | and here^. | {2:and} here. | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) -- Folding an empty line does not remove Cap in next line @@ -149,8 +148,7 @@ describe("'spell'", function() Not | {10:^+-- 2 lines: and here.·························································}| {2:and} here. | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) -- Folding the end of a sentence does not remove Cap in next line @@ -161,9 +159,7 @@ describe("'spell'", function() {2:another} missing cap her^e | {10:+-- 2 lines: Not·······························································}| {2:and} here. | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) -- Cap is correctly applied in the first row of a window @@ -172,10 +168,7 @@ describe("'spell'", function() {2:another} missing cap her^e | {10:+-- 2 lines: Not·······························································}| {2:and} here. | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) -- Adding an empty line does not remove Cap in "mod_bot" area @@ -186,8 +179,7 @@ describe("'spell'", function() {2:another} missing cap here | {10:+-- 2 lines: Not·······························································}| {2:and} here. | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) -- Multiple empty lines does not remove Cap in the line after @@ -220,9 +212,7 @@ describe("'spell'", function() test test test test$ | | {2:end} | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {9:-- INSERT --} | ]]) feed('x') @@ -231,9 +221,7 @@ describe("'spell'", function() test test test test$ | | {2:end} | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {9:-- INSERT --} | ]]) end) @@ -251,10 +239,7 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:spelin^g}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed(']s') @@ -262,10 +247,7 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:speling}{7: }{8:^mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed(']s') @@ -273,24 +255,18 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:^speling}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {6:search hit BOTTOM, continuing at TOP} | ]]) exec('echo ""') - local ns = meths.create_namespace("spell") + local ns = api.nvim_create_namespace('spell') -- extmark with spell=true enables spell - local id = curbufmeths.set_extmark(ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) + local id = api.nvim_buf_set_extmark(0, ns, 1, 4, { end_row = 1, end_col = 10, spell = true }) screen:expect([[ {3:#include }{4:<stdbool.h>} | {5:bool} {1:func}({5:void}); | {7:// I am a }{8:^speling}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed('[s') @@ -298,23 +274,17 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} {1:^func}({5:void}); | {7:// I am a }{8:speling}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) - curbufmeths.del_extmark(ns, id) + api.nvim_buf_del_extmark(0, ns, id) -- extmark with spell=false disables spell - id = curbufmeths.set_extmark(ns, 2, 18, { end_row = 2, end_col = 26, spell = false }) + id = api.nvim_buf_set_extmark(0, ns, 2, 18, { end_row = 2, end_col = 26, spell = false }) screen:expect([[ {3:#include }{4:<stdbool.h>} | {5:bool} ^func({5:void}); | {7:// I am a }{8:speling}{7: mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed('[s') @@ -322,22 +292,16 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:^speling}{7: mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {6:search hit TOP, continuing at BOTTOM} | ]]) exec('echo ""') - curbufmeths.del_extmark(ns, id) + api.nvim_buf_del_extmark(0, ns, id) screen:expect([[ {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:^speling}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed(']s') @@ -345,10 +309,7 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:speling}{7: }{8:^mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) -- "noplainbuffer" shouldn't change spellchecking behavior with syntax enabled @@ -359,10 +320,7 @@ describe("'spell'", function() {3:#include }{4:<stdbool.h>} | {5:bool} func({5:void}); | {7:// I am a }{8:^speling}{7: }{8:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) -- no spellchecking with "noplainbuffer" and syntax disabled @@ -371,10 +329,7 @@ describe("'spell'", function() #include <stdbool.h> | bool func(void); | // I am a ^speling mistakke | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed(']s') @@ -382,10 +337,7 @@ describe("'spell'", function() #include <stdbool.h> | bool func(void); | // I am a ^speling mistakke | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {6:search hit BOTTOM, continuing at TOP} | ]]) exec('echo ""') @@ -395,10 +347,7 @@ describe("'spell'", function() #include <{1:stdbool}.h> | {1:bool} {1:func}(void); | // I am a {1:^speling} {1:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) feed('[s') @@ -406,10 +355,7 @@ describe("'spell'", function() #include <{1:stdbool}.h> | {1:bool} {1:^func}(void); | // I am a {1:speling} {1:mistakke} | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) @@ -421,8 +367,8 @@ describe("'spell'", function() syntax match Constant "^.*$" call setline(1, "This is some text without any spell errors.") ]]) - local ns = meths.create_namespace("spell") - curbufmeths.set_extmark(ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) + local ns = api.nvim_create_namespace('spell') + api.nvim_buf_set_extmark(0, ns, 0, 0, { hl_group = 'WarningMsg', end_col = 43 }) screen:expect([[ {6:^This is some text without any spell errors.}| {0:~ }| diff --git a/test/functional/ui/statuscolumn_spec.lua b/test/functional/ui/statuscolumn_spec.lua index 6eaf15cfad..41406a5860 100644 --- a/test/functional/ui/statuscolumn_spec.lua +++ b/test/functional/ui/statuscolumn_spec.lua @@ -7,11 +7,11 @@ local exec = helpers.exec local eval = helpers.eval local exec_lua = helpers.exec_lua local feed = helpers.feed -local meths = helpers.meths +local api = helpers.api local pcall_err = helpers.pcall_err local assert_alive = helpers.assert_alive -local mousemodels = { "extend", "popup", "popup_setpos" } +local mousemodels = { 'extend', 'popup', 'popup_setpos' } describe('statuscolumn', function() local screen @@ -23,7 +23,9 @@ describe('statuscolumn', function() end) it("fails with invalid 'statuscolumn'", function() - command([[set stc=%{v:relnum?v:relnum:(v:lnum==5?invalid:v:lnum)}\ ]]) + command( + [[set stc=%{v:relnum?v:relnum:(v:lnum==5?'truncate':v:lnum)}%{!v:relnum&&v:lnum==5?invalid:''}\ ]] + ) screen:expect([[ 4 aaaaa | 3 aaaaa | @@ -43,6 +45,22 @@ describe('statuscolumn', function() command('norm 5G') eq('Vim(redraw):E121: Undefined variable: invalid', pcall_err(command, 'redraw!')) eq('', eval('&statuscolumn')) + screen:expect([[ + 4 aaaaa | + 5 ^aaaaa | + 6 aaaaa | + 7 aaaaa | + 8 aaaaa | + 9 aaaaa | + 10 aaaaa | + 11 aaaaa | + 12 aaaaa | + 13 aaaaa | + 14 aaaaa | + 15 aaaaa | + 16 aaaaa | + | + ]]) end) it("widens with irregular 'statuscolumn' width", function() @@ -59,6 +77,18 @@ describe('statuscolumn', function() 1 aaaaa | | ]]) + -- Doesn't crash when trying to fill click defs that do not fit (#26845) + command('norm gg') + command([=[ + set stc=%@Click@%{v:relnum?v:relnum:(v:lnum==5?'bbbbb':v:lnum)}%T + norm 5Gzt | redraw! + ]=]) + screen:expect([[ + bbbbba^eaaa | + 1 aaaaa | + 2 aaaaa | + | + ]]) end) it("works with 'number' and 'relativenumber'", function() @@ -125,12 +155,14 @@ describe('statuscolumn', function() end) it("works with highlighted 'statuscolumn'", function() - command([[set stc=%#NonText#%{&nu?v:lnum:''}]] .. - [[%=%{&rnu&&(v:lnum%2)?'\ '.v:relnum:''}]] .. - [[%#LineNr#%{&rnu&&!(v:lnum%2)?'\ '.v:relnum:''}│]]) + command( + [[set stc=%#NonText#%{&nu?v:lnum:''}]] + .. [[%=%{&rnu&&(v:lnum%2)?'\ '.v:relnum:''}]] + .. [[%#LineNr#%{&rnu&&!(v:lnum%2)?'\ '.v:relnum:''}│]] + ) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, - [1] = {foreground = Screen.colors.Brown}, + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { foreground = Screen.colors.Brown }, }) screen:expect([[ {0:4 }{1:│}aaaaa | @@ -188,13 +220,13 @@ describe('statuscolumn', function() command([[set stc=%C%s%=%{v:virtnum?'':v:lnum}│\ ]]) command("call setline(1,repeat([repeat('aaaaa',10)],16))") screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, - [1] = {foreground = Screen.colors.Brown}, - [2] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey}, - [3] = {foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey}, - [4] = {bold = true, foreground = Screen.colors.Brown}, - [5] = {foreground = Screen.colors.Red}, - [6] = {foreground = Screen.colors.Red, background = Screen.colors.LightGrey}, + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { foreground = Screen.colors.Brown }, + [2] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.WebGrey }, + [3] = { foreground = Screen.colors.DarkBlue, background = Screen.colors.LightGrey }, + [4] = { bold = true, foreground = Screen.colors.Brown }, + [5] = { foreground = Screen.colors.Red }, + [6] = { foreground = Screen.colors.Red, background = Screen.colors.LightGrey }, }) command('hi! CursorLine guifg=Red guibg=NONE') screen:expect([[ @@ -418,7 +450,9 @@ describe('statuscolumn', function() vim.api.nvim_buf_set_extmark(0, ns, 4, 0, { virt_lines = {{{"virt_line", ""}}} }) ]]) command('set foldcolumn=0 signcolumn=no') - command([[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]]) + command( + [[set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum}]] + ) screen:expect([[ {1:buffer 0 4}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {1:wrapped 1 4}aaaaaaaa | @@ -451,9 +485,7 @@ describe('statuscolumn', function() {4:wrapped 1 15}{5:aaaaaaaaa^ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}| {4:wrapped 2 15}{5:aaaaaaaaaaaaaaaaaaa }| {1:virtual-1 15}END | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) -- Also test virt_lines when 'cpoptions' includes "n" @@ -478,19 +510,57 @@ describe('statuscolumn', function() {0:~ }| | ]]) + -- Also test "col_rows" code path for 'relativenumber' cursor movement + command([[ + set cpoptions-=n nocursorline relativenumber + set stc=%{v:virtnum<0?'virtual':(!v:virtnum?'buffer':'wrapped')}%=%{'\ '.v:virtnum.'\ '.v:lnum.'\ '.v:relnum} + ]]) + screen:expect([[ + {1:buffer 0 12 3}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 12 3}aaaaaaaaaaa | + {1:buffer 0 13 2}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 13 2}aaaaaaaaaaa | + {1:buffer 0 14 1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 14 1}aaaaaaaaaaa | + {1:buffer 0 15 0}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 15 0}aaaaaaaaaaa^ aaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 2 15 0}aaaaaaaaaaaaaaaaaaaaaaa | + {1:virtual-3 15 0}virt_line1 | + {1:virtual-2 15 0}virt_line2 | + {1:virtual-1 15 0}END | + {0:~ }| + | + ]]) + feed('kk') + screen:expect([[ + {1:buffer 0 12 1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 12 1}aaaaaaaaaaa | + {1:buffer 0 13 0}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 13 0}aaaaaaaaaa^a | + {1:buffer 0 14 1}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 14 1}aaaaaaaaaaa | + {1:buffer 0 15 2}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 1 15 2}aaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaa| + {1:wrapped 2 15 2}aaaaaaaaaaaaaaaaaaaaaaa | + {1:virtual-3 15 2}virt_line1 | + {1:virtual-2 15 2}virt_line2 | + {1:virtual-1 15 2}END | + {0:~ }| + | + ]]) end) it('does not corrupt the screen with minwid sign item', function() screen:try_resize(screen._width, 3) screen:set_default_attr_ids({ - [0] = {foreground = Screen.colors.Brown}, - [1] = {foreground = Screen.colors.Blue4, background = Screen.colors.Gray}, + [0] = { foreground = Screen.colors.Brown }, + [1] = { foreground = Screen.colors.Blue4, background = Screen.colors.Gray }, }) command([[set stc=%6s\ %l]]) exec_lua('vim.api.nvim_buf_set_extmark(0, ns, 7, 0, {sign_text = "𒀀"})') screen:expect([[ - {0: 𒀀 8}^aaaaa | - {0: }{1: }{0: 9}aaaaa | + {0: 𒀀 8 }^aaaaa | + {0: }{1: }{0: 9 }aaaaa | | ]]) end) @@ -511,92 +581,85 @@ describe('statuscolumn', function() end) it('clicks work with mousemodel=' .. model, function() - meths.set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 2 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 3 l 4', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 0, 0) - eq('0 4 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 1 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 2 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 3 r 7', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 0) - eq('0 4 r 7', eval("g:testvar")) + api.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%=%l%T', {}) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) + eq('0 1 l 4', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) + eq('0 2 l 4', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) + eq('0 3 l 4', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) + eq('0 4 l 4', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 0) + eq('0 1 r 7', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 0) + eq('0 2 r 7', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 0) + eq('0 3 r 7', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 0) + eq('0 4 r 7', eval('g:testvar')) command('rightbelow vsplit') - meths.input_mouse('left', 'press', '', 0, 0, 27) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 27) - eq('0 1 r 7', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 0, 27) + eq('0 1 l 4', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 27) + eq('0 1 r 7', eval('g:testvar')) command('setlocal rightleft') - meths.input_mouse('left', 'press', '', 0, 0, 52) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 52) - eq('0 1 r 7', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 0, 52) + eq('0 1 l 4', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 52) + eq('0 1 r 7', eval('g:testvar')) command('wincmd H') - meths.input_mouse('left', 'press', '', 0, 0, 25) - eq('0 1 l 4', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 3, 25) - eq('0 1 r 7', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 0, 25) + eq('0 1 l 4', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 3, 25) + eq('0 1 r 7', eval('g:testvar')) command('close') command('set laststatus=2 winbar=%f') command('let g:testvar = ""') -- Check that winbar click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 0, 0) - eq('', eval("g:testvar")) + api.nvim_input_mouse('right', 'press', '', 0, 0, 0) + eq('', eval('g:testvar')) -- Check that statusline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 12, 0) - eq('', eval("g:testvar")) + api.nvim_input_mouse('right', 'press', '', 0, 12, 0) + eq('', eval('g:testvar')) -- Check that cmdline click doesn't register as statuscolumn click - meths.input_mouse('right', 'press', '', 0, 13, 0) - eq('', eval("g:testvar")) + api.nvim_input_mouse('right', 'press', '', 0, 13, 0) + eq('', eval('g:testvar')) end) it('clicks and highlights work with control characters', function() - meths.set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) - screen:expect{grid=[[ - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + api.nvim_set_option_value('statuscolumn', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + screen:expect { + grid = [[ + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*4 {1:^I}{0:^A^I^A^I}{1:^A}^aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | - {1:^I}{0:^A^I^A^I}{1:^A}aaaaa | + {1:^I}{0:^A^I^A^I}{1:^A}aaaaa |*8 | - ]], attr_ids={ - [0] = {foreground = Screen.colors.Blue, bold = true}; -- NonText - [1] = {foreground = Screen.colors.Brown}; -- LineNr - }} - meths.input_mouse('right', 'press', '', 0, 4, 3) - eq('', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 5, 8) - eq('', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 4) - eq('0 1 r 10', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 7, 7) - eq('0 1 l 11', eval("g:testvar")) + ]], + attr_ids = { + [0] = { foreground = Screen.colors.Blue, bold = true }, -- NonText + [1] = { foreground = Screen.colors.Brown }, -- LineNr + }, + } + api.nvim_input_mouse('right', 'press', '', 0, 4, 3) + eq('', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 5, 8) + eq('', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 4) + eq('0 1 r 10', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 7, 7) + eq('0 1 l 11', eval('g:testvar')) end) it('popupmenu callback does not drag mouse on close', function() screen:try_resize(screen._width, 2) screen:set_default_attr_ids({ - [0] = {foreground = Screen.colors.Brown}, - [1] = {background = Screen.colors.Plum1}, + [0] = { foreground = Screen.colors.Brown }, + [1] = { background = Screen.colors.Plum1 }, }) - meths.set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {}) + api.nvim_set_option_value('statuscolumn', '%0@MyClickFunc@%l%T', {}) exec([[ function! MyClickFunc(minwid, clicks, button, mods) let g:testvar = printf("%d %d %s %d", a:minwid, a:clicks, a:button, getmousepos().line) @@ -605,26 +668,26 @@ describe('statuscolumn', function() endfunction ]]) -- clicking an item does not drag mouse - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {0:8 }^aaaaa | {1: Echo } | ]]) - meths.input_mouse('left', 'press', '', 0, 1, 5) - meths.input_mouse('left', 'release', '', 0, 1, 5) + api.nvim_input_mouse('left', 'press', '', 0, 1, 5) + api.nvim_input_mouse('left', 'release', '', 0, 1, 5) screen:expect([[ {0:8 }^aaaaa | 0 1 l 8 | ]]) command('echo') -- clicking outside to close the menu does not drag mouse - meths.input_mouse('left', 'press', '', 0, 0, 0) + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) screen:expect([[ {0:8 }^aaaaa | {1: Echo } | ]]) - meths.input_mouse('left', 'press', '', 0, 0, 10) - meths.input_mouse('left', 'release', '', 0, 0, 10) + api.nvim_input_mouse('left', 'press', '', 0, 0, 10) + api.nvim_input_mouse('left', 'release', '', 0, 0, 10) screen:expect([[ {0:8 }^aaaaa | | @@ -661,7 +724,9 @@ describe('statuscolumn', function() it('works with foldcolumn', function() -- Fits maximum multibyte foldcolumn #21759 command([[set stc=%C%=%l\ fdc=9 fillchars=foldsep:𒀀]]) - for _ = 0,8 do command('norm zfjzo') end + for _ = 0, 8 do + command('norm zfjzo') + end -- 'statuscolumn' is not drawn for `virt_lines_leftcol` lines exec_lua([[ vim.api.nvim_buf_set_extmark(0, ns, 6, 0, { @@ -685,7 +750,7 @@ describe('statuscolumn', function() 14 aaaaa | | ]]) - command('set stc=') -- also for the default fold column + command('set stc=') -- also for the default fold column screen:expect_unchanged() -- 'statuscolumn' is not too wide with custom (bogus) fold column command([[set stc=%{foldlevel(v:lnum)>0?repeat('-',foldlevel(v:lnum)):''}%=%l\ ]]) @@ -702,8 +767,7 @@ describe('statuscolumn', function() ---------8 aaaaa | virt | ---------9 aaaaa | - ~ | - ~ | + ~ |*2 | ]]) end) @@ -718,11 +782,7 @@ describe('statuscolumn', function() [No Name] [+] | :1set stc=%^l | :2 | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 [Command Line] | : | ]]) @@ -749,9 +809,7 @@ describe('statuscolumn', function() screen:expect([[ aaaaa | ^aaaaa | - aaaaa | - aaaaa | - aaaaa | + aaaaa |*3 | ]]) -- width correctly estimated with "w_nrwidth_line_count" when setting 'nu' @@ -766,7 +824,7 @@ describe('statuscolumn', function() ]]) end) - it("has correct width with custom sign column when (un)placing signs", function() + it('has correct width with custom sign column when (un)placing signs', function() screen:try_resize(screen._width, 3) exec_lua([[ vim.cmd.norm('gg') @@ -823,13 +881,13 @@ describe('statuscolumn', function() 2 ssssaaaaa | | ]]) - exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id1)") + exec_lua('vim.api.nvim_buf_del_extmark(0, ns, id1)') screen:expect([[ 1 ^aaaaa | 2 ssaaaaa | | ]]) - exec_lua("vim.api.nvim_buf_del_extmark(0, ns, id2)") + exec_lua('vim.api.nvim_buf_del_extmark(0, ns, id2)') screen:expect([[ 1 ^aaaaa | 2 aaaaa | @@ -845,7 +903,7 @@ describe('statuscolumn', function() ]]) end) - it("is only evaluated twice, once to estimate and once to draw", function() + it('is only evaluated twice, once to estimate and once to draw', function() command([[ let g:stcnr = 0 func! Stc() @@ -869,4 +927,17 @@ describe('statuscolumn', function() | ]]) end) + + it('line increase properly redraws buffer text with relativenumber #27709', function() + screen:try_resize(33, 4) + command([[set rnu nuw=3 stc=%l\ ]]) + command('call setline(1, range(1, 99))') + feed('Gyyp') + screen:expect([[ + 98 98 | + 99 99 | + 100 ^99 | + | + ]]) + end) end) diff --git a/test/functional/ui/statusline_spec.lua b/test/functional/ui/statusline_spec.lua index 182e0cdadf..fee4b64d44 100644 --- a/test/functional/ui/statusline_spec.lua +++ b/test/functional/ui/statusline_spec.lua @@ -5,14 +5,14 @@ local clear = helpers.clear local command = helpers.command local feed = helpers.feed local eq = helpers.eq -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local exec = helpers.exec local exec_lua = helpers.exec_lua local eval = helpers.eval -local sleep = helpers.sleep +local sleep = vim.uv.sleep -local mousemodels = { "extend", "popup", "popup_setpos" } +local mousemodels = { 'extend', 'popup', 'popup_setpos' } for _, model in ipairs(mousemodels) do describe('statusline clicks with mousemodel=' .. model, function() @@ -22,8 +22,8 @@ for _, model in ipairs(mousemodels) do clear() screen = Screen.new(40, 8) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText - [1] = {bold = true, reverse = true}; -- StatusLine + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { bold = true, reverse = true }, -- StatusLine }) screen:attach() command('set laststatus=2 mousemodel=' .. model) @@ -39,80 +39,84 @@ for _, model in ipairs(mousemodels) do end) it('works', function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 16) - eq('', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 29) - eq('', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 2 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 3 l', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 4 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 28) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 28) - eq('0 2 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 28) - eq('0 3 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 28) - eq('0 4 r', eval("g:testvar")) + api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_input_mouse('left', 'press', '', 0, 6, 16) + eq('', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 29) + eq('', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 2 l', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 3 l', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 4 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 28) + eq('0 1 r', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 28) + eq('0 2 r', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 28) + eq('0 3 r', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 28) + eq('0 4 r', eval('g:testvar')) end) it('works with control characters and highlight', function() - meths.set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) - screen:expect{grid=[[ + api.nvim_set_option_value('statusline', '\t%#NonText#\1%0@MyClickFunc@\t\1%T\t%##\1', {}) + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:^I}{0:^A^I^A^I}{1:^A }| | - ]]} - meths.input_mouse('right', 'press', '', 0, 6, 3) - eq('', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 8) - eq('', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 4) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 7) - eq('0 1 l', eval("g:testvar")) + ]], + } + api.nvim_input_mouse('right', 'press', '', 0, 6, 3) + eq('', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 8) + eq('', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 4) + eq('0 1 r', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 7) + eq('0 1 l', eval('g:testvar')) end) it('works for winbar', function() - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 0, 17) - eq('0 1 r', eval("g:testvar")) + api.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 0, 17) + eq('0 1 r', eval('g:testvar')) end) it('works for winbar in floating window', function() - meths.open_win(0, true, { width=30, height=4, relative='editor', row=1, col=5, - border = "single" }) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', - { scope = 'local' }) - meths.input_mouse('left', 'press', '', 0, 2, 23) - eq('0 1 l', eval("g:testvar")) + api.nvim_open_win( + 0, + true, + { width = 30, height = 4, relative = 'editor', row = 1, col = 5, border = 'single' } + ) + api.nvim_set_option_value( + 'winbar', + 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', + { scope = 'local' } + ) + api.nvim_input_mouse('left', 'press', '', 0, 2, 23) + eq('0 1 l', eval('g:testvar')) end) it('works when there are multiple windows', function() command('split') - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 0, 17) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 4, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('middle', 'press', '', 0, 3, 17) - eq('0 1 m', eval("g:testvar")) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) + api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_set_option_value('winbar', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_input_mouse('left', 'press', '', 0, 0, 17) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 4, 17) + eq('0 1 r', eval('g:testvar')) + api.nvim_input_mouse('middle', 'press', '', 0, 3, 17) + eq('0 1 m', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval('g:testvar')) end) it('works with Lua function', function() @@ -121,101 +125,107 @@ for _, model in ipairs(mousemodels) do vim.g.testvar = string.format("%d %d %s", minwid, clicks, button) end ]]) - meths.set_option_value('statusline', 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 17) - eq('0 1 l', eval("g:testvar")) + api.nvim_set_option_value( + 'statusline', + 'Not clicky stuff %0@v:lua.clicky_func@Clicky stuff%T', + {} + ) + api.nvim_input_mouse('left', 'press', '', 0, 6, 17) + eq('0 1 l', eval('g:testvar')) end) it('ignores unsupported click items', function() command('tabnew | tabprevious') - meths.set_option_value('statusline', '%2TNot clicky stuff%T', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(1, meths.get_current_tabpage().id) - meths.set_option_value('statusline', '%2XNot clicky stuff%X', {}) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq(2, #meths.list_tabpages()) + api.nvim_set_option_value('statusline', '%2TNot clicky stuff%T', {}) + api.nvim_input_mouse('left', 'press', '', 0, 6, 0) + eq(1, api.nvim_get_current_tabpage()) + api.nvim_set_option_value('statusline', '%2XNot clicky stuff%X', {}) + api.nvim_input_mouse('left', 'press', '', 0, 6, 0) + eq(2, #api.nvim_list_tabpages()) end) it("right click works when statusline isn't focused #18994", function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 1 r', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 17) - eq('0 2 r', eval("g:testvar")) + api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_input_mouse('right', 'press', '', 0, 6, 17) + eq('0 1 r', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 17) + eq('0 2 r', eval('g:testvar')) end) - it("works with modifiers #18994", function() - meths.set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) + it('works with modifiers #18994', function() + api.nvim_set_option_value('statusline', 'Not clicky stuff %0@MyClickFunc@Clicky stuff%T', {}) -- Note: alternate between left and right mouse buttons to avoid triggering multiclicks - meths.input_mouse('left', 'press', 'S', 0, 6, 17) - eq('0 1 l(s )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'S', 0, 6, 17) - eq('0 1 r(s )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'A', 0, 6, 17) - eq('0 1 l( a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'A', 0, 6, 17) - eq('0 1 r( a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'AS', 0, 6, 17) - eq('0 1 l(s a )', eval("g:testvar")) - meths.input_mouse('right', 'press', 'AS', 0, 6, 17) - eq('0 1 r(s a )', eval("g:testvar")) - meths.input_mouse('left', 'press', 'T', 0, 6, 17) - eq('0 1 l( m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'T', 0, 6, 17) - eq('0 1 r( m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'TS', 0, 6, 17) - eq('0 1 l(s m)', eval("g:testvar")) - meths.input_mouse('right', 'press', 'TS', 0, 6, 17) - eq('0 1 r(s m)', eval("g:testvar")) - meths.input_mouse('left', 'press', 'C', 0, 6, 17) - eq('0 1 l( c )', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', 'S', 0, 6, 17) + eq('0 1 l(s )', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', 'S', 0, 6, 17) + eq('0 1 r(s )', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', 'A', 0, 6, 17) + eq('0 1 l( a )', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', 'A', 0, 6, 17) + eq('0 1 r( a )', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', 'AS', 0, 6, 17) + eq('0 1 l(s a )', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', 'AS', 0, 6, 17) + eq('0 1 r(s a )', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', 'T', 0, 6, 17) + eq('0 1 l( m)', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', 'T', 0, 6, 17) + eq('0 1 r( m)', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', 'TS', 0, 6, 17) + eq('0 1 l(s m)', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', 'TS', 0, 6, 17) + eq('0 1 r(s m)', eval('g:testvar')) + api.nvim_input_mouse('left', 'press', 'C', 0, 6, 17) + eq('0 1 l( c )', eval('g:testvar')) -- <C-RightMouse> is for tag jump end) - it("works for global statusline with vertical splits #19186", function() + it('works for global statusline with vertical splits #19186', function() command('set laststatus=3') - meths.set_option_value('statusline', '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', {}) + api.nvim_set_option_value( + 'statusline', + '%0@MyClickFunc@Clicky stuff%T %= %0@MyClickFunc@Clicky stuff%T', + {} + ) command('vsplit') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ │ | - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| - {0:~ }│{0:~ }| + {0:~ }│{0:~ }|*5 {1:Clicky stuff Clicky stuff}| | - ]]} + ]], + } -- clickable area on the right - meths.input_mouse('left', 'press', '', 0, 6, 35) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 35) - eq('0 1 r', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 6, 35) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 35) + eq('0 1 r', eval('g:testvar')) -- clickable area on the left - meths.input_mouse('left', 'press', '', 0, 6, 5) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 5) - eq('0 1 r', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 6, 5) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 5) + eq('0 1 r', eval('g:testvar')) end) it('no memory leak with zero-width click labels', function() command([[ let &stl = '%@Test@%T%@MyClickFunc@%=%T%@Test@' ]]) - meths.input_mouse('left', 'press', '', 0, 6, 0) - eq('0 1 l', eval("g:testvar")) - meths.input_mouse('right', 'press', '', 0, 6, 39) - eq('0 1 r', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 6, 0) + eq('0 1 l', eval('g:testvar')) + api.nvim_input_mouse('right', 'press', '', 0, 6, 39) + eq('0 1 r', eval('g:testvar')) end) it('no memory leak with truncated click labels', function() command([[ let &stl = '%@MyClickFunc@foo%X' .. repeat('a', 40) .. '%<t%@Test@bar%X%@Test@baz' ]]) - meths.input_mouse('left', 'press', '', 0, 6, 2) - eq('0 1 l', eval("g:testvar")) + api.nvim_input_mouse('left', 'press', '', 0, 6, 2) + eq('0 1 l', eval('g:testvar')) end) end) end @@ -228,11 +238,11 @@ describe('global statusline', function() screen = Screen.new(60, 16) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}; - [2] = {bold = true, reverse = true}; - [3] = {bold = true}; - [4] = {reverse = true}; - [5] = {bold = true, foreground = Screen.colors.Fuchsia}; + [1] = { bold = true, foreground = Screen.colors.Blue }, + [2] = { bold = true, reverse = true }, + [3] = { bold = true }, + [4] = { reverse = true }, + [5] = { bold = true, foreground = Screen.colors.Fuchsia }, }) command('set laststatus=3') command('set ruler') @@ -241,39 +251,16 @@ describe('global statusline', function() it('works', function() screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*13 {2:[No Name] 0,0-1 All}| | ]]) feed('i<CR><CR>') screen:expect([[ - | - | + |*2 ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*11 {2:[No Name] [+] 3,1 All}| {3:-- INSERT --} | ]]) @@ -283,9 +270,7 @@ describe('global statusline', function() command('vsplit | split | vsplit | vsplit | wincmd l | split | 2wincmd l | split') screen:expect([[ │ │ │^ | - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }|*3 {1:~ }├────────────────┤{1:~}│{1:~ }| {1:~ }│ │{1:~}│{1:~ }| {1:~ }│{1:~ }│{1:~}│{1:~ }| @@ -293,9 +278,7 @@ describe('global statusline', function() {1:~ }│{1:~ }│{1:~}│ | ────────────────────┴────────────────┴─┤{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] 0,0-1 All}| | ]]) @@ -305,39 +288,14 @@ describe('global statusline', function() command('set laststatus=1') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*14 0,0-1 All | ]]) command('set laststatus=3') screen:expect([[ ^ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*13 {2:[No Name] 0,0-1 All}| | ]]) @@ -346,9 +304,7 @@ describe('global statusline', function() command('set laststatus=2') screen:expect([[ │ │ │^ | - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }|*3 {1:~ }│{4:< Name] 0,0-1 }│{1:~}│{1:~ }| {1:~ }│ │{1:~}│{1:~ }| {1:~ }│{1:~ }│{1:~}│{1:~ }| @@ -356,9 +312,7 @@ describe('global statusline', function() {1:~ }│{1:~ }│{1:~}│ | {4:<No Name] 0,0-1 All < Name] 0,0-1 <}│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {4:[No Name] 0,0-1 All <No Name] 0,0-1 All}| | ]]) @@ -366,9 +320,7 @@ describe('global statusline', function() command('set laststatus=3') screen:expect([[ │ │ │^ | - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }|*3 {1:~ }├────────────────┤{1:~}│{1:~ }| {1:~ }│ │{1:~}│{1:~ }| {1:~ }│{1:~ }│{1:~}│{1:~ }| @@ -376,9 +328,7 @@ describe('global statusline', function() {1:~ }│{1:~ }│{1:~}│ | ────────────────────┴────────────────┴─┤{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] 0,0-1 All}| | ]]) @@ -386,9 +336,7 @@ describe('global statusline', function() command('set laststatus=0') screen:expect([[ │ │ │^ | - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }|*3 {1:~ }│{4:< Name] 0,0-1 }│{1:~}│{1:~ }| {1:~ }│ │{1:~}│{1:~ }| {1:~ }│{1:~ }│{1:~}│{1:~ }| @@ -396,19 +344,14 @@ describe('global statusline', function() {1:~ }│{1:~ }│{1:~}│ | {4:<No Name] 0,0-1 All < Name] 0,0-1 <}│{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*4 0,0-1 All | ]]) command('set laststatus=3') screen:expect([[ │ │ │^ | - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| - {1:~ }│{1:~ }│{1:~}│{1:~ }| + {1:~ }│{1:~ }│{1:~}│{1:~ }|*3 {1:~ }├────────────────┤{1:~}│{1:~ }| {1:~ }│ │{1:~}│{1:~ }| {1:~ }│{1:~ }│{1:~}│{1:~ }| @@ -416,55 +359,49 @@ describe('global statusline', function() {1:~ }│{1:~ }│{1:~}│ | ────────────────────┴────────────────┴─┤{1:~ }| │{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*3 {2:[No Name] 0,0-1 All}| | ]]) end) it('win_move_statusline() can reduce cmdheight to 1', function() - eq(1, meths.get_option_value('cmdheight', {})) - funcs.win_move_statusline(0, -1) - eq(2, meths.get_option_value('cmdheight', {})) - funcs.win_move_statusline(0, -1) - eq(3, meths.get_option_value('cmdheight', {})) - funcs.win_move_statusline(0, 1) - eq(2, meths.get_option_value('cmdheight', {})) - funcs.win_move_statusline(0, 1) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, api.nvim_get_option_value('cmdheight', {})) + fn.win_move_statusline(0, -1) + eq(2, api.nvim_get_option_value('cmdheight', {})) + fn.win_move_statusline(0, -1) + eq(3, api.nvim_get_option_value('cmdheight', {})) + fn.win_move_statusline(0, 1) + eq(2, api.nvim_get_option_value('cmdheight', {})) + fn.win_move_statusline(0, 1) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) it('mouse dragging can reduce cmdheight to 1', function() command('set mouse=a') - meths.input_mouse('left', 'press', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 12, 10) - eq(3, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 13, 10) - eq(2, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 15, 10) - eq(1, meths.get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 0, 14, 10) - eq(1, meths.get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'press', '', 0, 14, 10) + eq(1, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 12, 10) + eq(3, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 13, 10) + eq(2, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 15, 10) + eq(1, api.nvim_get_option_value('cmdheight', {})) + api.nvim_input_mouse('left', 'drag', '', 0, 14, 10) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) it('cmdline row is correct after setting cmdheight #20514', function() command('botright split test/functional/fixtures/bigfile.txt') - meths.set_option_value('cmdheight', 1, {}) + api.nvim_set_option_value('cmdheight', 1, {}) feed('L') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ────────────────────────────────────────────────────────────| 0000;<control>;Cc;0;BN;;;;;N;NULL;;;; | 0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; | @@ -479,11 +416,7 @@ describe('global statusline', function() feed('j') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ────────────────────────────────────────────────────────────| 0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; | 0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | @@ -495,15 +428,11 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option_value('showtabline', 2, {}) + api.nvim_set_option_value('showtabline', 2, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ────────────────────────────────────────────────────────────| 0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | @@ -514,15 +443,11 @@ describe('global statusline', function() {2:test/functional/fixtures/bigfile.txt 8,1 0%}| | ]]) - meths.set_option_value('cmdheight', 0, {}) + api.nvim_set_option_value('cmdheight', 0, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ────────────────────────────────────────────────────────────| 0001;<control>;Cc;0;BN;;;;;N;START OF HEADING;;;; | 0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | @@ -533,15 +458,11 @@ describe('global statusline', function() ^0007;<control>;Cc;0;BN;;;;;N;BELL;;;; | {2:test/functional/fixtures/bigfile.txt 8,1 0%}| ]]) - meths.set_option_value('cmdheight', 1, {}) + api.nvim_set_option_value('cmdheight', 1, {}) screen:expect([[ {3: }{5:2}{3: t/f/f/bigfile.txt }{4: }| | - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*5 ────────────────────────────────────────────────────────────| 0002;<control>;Cc;0;BN;;;;;N;START OF TEXT;;;; | 0003;<control>;Cc;0;BN;;;;;N;END OF TEXT;;;; | @@ -557,8 +478,8 @@ end) it('statusline does not crash if it has Arabic characters #19447', function() clear() - meths.set_option_value('statusline', 'غً', {}) - meths.set_option_value('laststatus', 2, {}) + api.nvim_set_option_value('statusline', 'غً', {}) + api.nvim_set_option_value('laststatus', 2, {}) command('redraw!') assert_alive() end) @@ -567,8 +488,8 @@ it('statusline is redrawn with :resize from <Cmd> mapping #19629', function() clear() local screen = Screen.new(40, 8) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [1] = {bold = true, reverse = true}, -- StatusLine + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { bold = true, reverse = true }, -- StatusLine }) screen:attach() exec([[ @@ -579,22 +500,14 @@ it('statusline is redrawn with :resize from <Cmd> mapping #19629', function() feed('<Up>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 {1:[No Name] }| - | - | + |*2 ]]) feed('<Down>') screen:expect([[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 {1:[No Name] }| | ]]) @@ -604,9 +517,9 @@ it('showcmdloc=statusline does not show if statusline is too narrow', function() clear() local screen = Screen.new(40, 8) screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [1] = {bold = true, reverse = true}, -- StatusLine - [2] = {reverse = true}, -- StatusLineNC + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { bold = true, reverse = true }, -- StatusLine + [2] = { reverse = true }, -- StatusLineNC }) screen:attach() command('set showcmd') @@ -614,11 +527,7 @@ it('showcmdloc=statusline does not show if statusline is too narrow', function() command('1vsplit') screen:expect([[ ^ │ | - {0:~}│{0:~ }| - {0:~}│{0:~ }| - {0:~}│{0:~ }| - {0:~}│{0:~ }| - {0:~}│{0:~ }| + {0:~}│{0:~ }|*5 {1:< }{2:[No Name] }| | ]]) @@ -668,8 +577,7 @@ it('statusline is redrawn on various state changes', function() screen:expect([[ ^ | ~ | - | - | + |*2 ]]) feed('qQ') screen:expect([[ @@ -682,8 +590,7 @@ it('statusline is redrawn on various state changes', function() screen:expect([[ ^ | ~ | - | - | + |*2 ]]) -- Visual mode change #23932 @@ -741,13 +648,13 @@ it('ruler is redrawn in cmdline with redrawstatus #22804', function() ]]) end) -it("shows correct ruler in cmdline with no statusline", function() +it('shows correct ruler in cmdline with no statusline', function() clear() local screen = Screen.new(30, 8) screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText - [2] = {bold = true, reverse = true}, -- StatusLine - [3] = {reverse = true}, -- StatusLineNC + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- StatusLine + [3] = { reverse = true }, -- StatusLineNC } screen:attach() -- Use long ruler to check 'ruler' with 'rulerformat' set has correct width. @@ -765,12 +672,10 @@ it("shows correct ruler in cmdline with no statusline", function() command '1wincmd w' screen:expect [[ ^ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:[No Name] 1longlonglong }| │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 3longlonglong | ]] -- Window 2 is current. It has no statusline, so cmdline should show its @@ -778,24 +683,20 @@ it("shows correct ruler in cmdline with no statusline", function() command '2wincmd w' screen:expect [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[No Name] 1longlonglong }| ^ │ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 2longlonglong | ]] -- Window 3 is current. Cmdline should again show its ruler. command '3wincmd w' screen:expect [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:[No Name] 1longlonglong }| │^ | - {1:~ }│{1:~ }| - {1:~ }│{1:~ }| + {1:~ }│{1:~ }|*2 3longlonglong | ]] end) @@ -805,15 +706,72 @@ it('uses "stl" and "stlnc" fillchars even if they are the same #19803', function local screen = Screen.new(53, 4) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText }) command('hi clear StatusLine') command('hi clear StatusLineNC') command('vsplit') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ │ | {1:~ }│{1:~ }| [No Name] [No Name] | | - ]]} + ]], + } +end) + +it('showcmdloc=statusline works with vertical splits', function() + clear() + local screen = Screen.new(53, 4) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- StatusLine + [3] = { reverse = true }, -- StatusLineNC + } + screen:attach() + command('rightbelow vsplit') + command('set showcmd showcmdloc=statusline') + feed('1234') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {3:[No Name] }{2:[No Name] 1234 }| + | + ]]) + feed('<Esc>') + command('set laststatus=3') + feed('1234') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {2:[No Name] 1234 }| + | + ]]) +end) + +it('keymap is shown with vertical splits #27269', function() + clear() + local screen = Screen.new(53, 4) + screen:set_default_attr_ids { + [1] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [2] = { bold = true, reverse = true }, -- StatusLine + [3] = { reverse = true }, -- StatusLineNC + } + screen:attach() + command('setlocal keymap=dvorak') + command('rightbelow vsplit') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {3:[No Name] <en-dv> }{2:[No Name] <en-dv> }| + | + ]]) + command('set laststatus=3') + screen:expect([[ + │^ | + {1:~ }│{1:~ }| + {2:[No Name] <en-dv> }| + | + ]]) end) diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua index 1391985823..5afc7dfe6c 100644 --- a/test/functional/ui/syntax_conceal_spec.lua +++ b/test/functional/ui/syntax_conceal_spec.lua @@ -11,26 +11,25 @@ describe('Screen', function() before_each(function() clear() - screen = Screen.new(nil,10) + screen = Screen.new(nil, 10) screen:attach() - screen:set_default_attr_ids( { - [0] = {bold=true, foreground=Screen.colors.Blue}, - [1] = {foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray}, - [2] = {bold = true, reverse = true}, - [3] = {reverse = true}, - [4] = {bold = true}, - [5] = {background = Screen.colors.Yellow}, - [6] = {background = Screen.colors.LightGrey}, - } ) + screen:set_default_attr_ids({ + [0] = { bold = true, foreground = Screen.colors.Blue }, + [1] = { foreground = Screen.colors.LightGrey, background = Screen.colors.DarkGray }, + [2] = { bold = true, reverse = true }, + [3] = { reverse = true }, + [4] = { bold = true }, + [5] = { background = Screen.colors.Yellow }, + [6] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + }) end) - describe("match and conceal", function() - + describe('match and conceal', function() before_each(function() - command("let &conceallevel=1") + command('let &conceallevel=1') end) - describe("multiple", function() + describe('multiple', function() before_each(function() insert([[ && @@ -43,124 +42,88 @@ describe('Screen', function() command("syn match dAmpersand '[&][&]' conceal cchar=∧") end) - it("double characters.", function() + it('double characters.', function() screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*6 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) it('double characters and move the cursor one line up.', function() - feed("k") + feed('k') screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*5 ^&& | | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) it('double characters and move the cursor to the beginning of the file.', function() - feed("gg") + feed('gg') screen:expect([[ ^&& | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*5 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) it('double characters and move the cursor to the second line in the file.', function() - feed("ggj") + feed('ggj') screen:expect([[ {1:∧} | ^&& | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + {1:∧} |*4 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) end) - it('double characters and then move the cursor to the beginning of the file and back to the end of the file.', function() - feed("ggG") - screen:expect([[ - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | - {1:∧} | + it( + 'double characters and then move the cursor to the beginning of the file and back to the end of the file.', + function() + feed('ggG') + screen:expect([[ + {1:∧} |*6 ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | ]]) - end) + end + ) end) -- multiple - it("keyword instances in initially in the document.", function() - feed("2ilambda<cr><ESC>") - command("let &conceallevel=1") - command("syn keyword kLambda lambda conceal cchar=λ") + it('keyword instances in initially in the document.', function() + feed('2ilambda<cr><ESC>') + command('let &conceallevel=1') + command('syn keyword kLambda lambda conceal cchar=λ') screen:expect([[ - {1:λ} | - {1:λ} | + {1:λ} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) -- Keyword - describe("regions in the document", function() - + describe('regions in the document', function() before_each(function() - feed("2") - insert("<r> a region of text </r>\n") - command("let &conceallevel=1") + feed('2') + insert('<r> a region of text </r>\n') + command('let &conceallevel=1') end) it('initially and conceal it.', function() command("syn region rText start='<r>' end='</r>' conceal cchar=R") screen:expect([[ - {1:R} | - {1:R} | + {1:R} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) @@ -170,246 +133,183 @@ describe('Screen', function() -- be replaced with cchar. command("syn region rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") screen:expect([[ - {1: } a region of text {1:-} | - {1: } a region of text {1:-} | + {1: } a region of text {1:-} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) - it('that are nested and conceal the nested region\'s start and end tags.', function() - command("syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-") - insert("<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n") + it("that are nested and conceal the nested region's start and end tags.", function() + command( + "syn region rText contains=rText matchgroup=rMatch start='<r>' end='</r>' concealends cchar=-" + ) + insert('<r> A region with <r> a nested <r> nested region.</r> </r> </r>\n') screen:expect([[ - {1: } a region of text {1:-} | - {1: } a region of text {1:-} | + {1: } a region of text {1:-} |*2 {1: } A region with {1: } a nested {1: } nested region.{1:-} | {1:-} {1:-} | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) end) -- regions in the document - describe("a region of text", function() + describe('a region of text', function() before_each(function() - command("syntax conceal on") - feed("2") - insert("<r> a region of text </r>\n") + command('syntax conceal on') + feed('2') + insert('<r> a region of text </r>\n') command("syn region rText start='<r>' end='</r>' cchar=-") end) - it("and turn on implicit concealing", function() + it('and turn on implicit concealing', function() screen:expect([[ - {1:-} | - {1:-} | + {1:-} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*6 | ]]) end) - it("and then turn on, then off, and then back on implicit concealing.", function() - command("syntax conceal off") - feed("2") - insert("<i> italian text </i>\n") + it('and then turn on, then off, and then back on implicit concealing.', function() + command('syntax conceal off') + feed('2') + insert('<i> italian text </i>\n') command("syn region iText start='<i>' end='</i>' cchar=*") screen:expect([[ - {1:-} | - {1:-} | - <i> italian text </i> | - <i> italian text </i> | + {1:-} |*2 + <i> italian text </i> |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) - command("syntax conceal on") + command('syntax conceal on') command("syn region iText start='<i>' end='</i>' cchar=*") screen:expect([[ - {1:-} | - {1:-} | - {1:*} | - {1:*} | + {1:-} |*2 + {1:*} |*2 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) end) -- a region of text (implicit concealing) - it("cursor position is correct when entering Insert mode with cocu=ni #13916", function() + it('cursor position is correct when entering Insert mode with cocu=ni #13916', function() insert([[foobarfoobarfoobar]]) -- move to end of line - feed("$") - command("set concealcursor=ni") - command("syn match Foo /foobar/ conceal cchar=&") + feed('$') + command('set concealcursor=ni') + command('syn match Foo /foobar/ conceal cchar=&') screen:expect([[ {1:&&&}^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 | ]]) - feed("i") + feed('i') -- cursor should stay in place, not jump to column 16 screen:expect([[ {1:&&&}^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*8 {4:-- INSERT --} | ]]) end) end) -- match and conceal - describe("let the conceal level be", function() + describe('let the conceal level be', function() before_each(function() - insert("// No Conceal\n") + insert('// No Conceal\n') insert('"Conceal without a cchar"\n') - insert("+ With cchar\n\n") + insert('+ With cchar\n\n') command("syn match noConceal '^//.*$'") - command("syn match concealNoCchar '\".\\{-}\"$' conceal") + command('syn match concealNoCchar \'".\\{-}"$\' conceal') command("syn match concealWCchar '^+.\\{-}$' conceal cchar=C") end) - it("0. No concealing.", function() - command("let &conceallevel=0") + it('0. No concealing.', function() + command('let &conceallevel=0') screen:expect([[ // No Conceal | "Conceal without a cchar" | + With cchar | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) - it("1. Conceal using cchar or reference listchars.", function() - command("let &conceallevel=1") + it('1. Conceal using cchar or reference listchars.', function() + command('let &conceallevel=1') screen:expect([[ // No Conceal | {1: } | {1:C} | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) - it("2. Hidden unless cchar is set.", function() - command("let &conceallevel=2") + it('2. Hidden unless cchar is set.', function() + command('let &conceallevel=2') screen:expect([[ // No Conceal | | {1:C} | | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) - it("3. Hide all concealed text.", function() - command("let &conceallevel=3") + it('3. Hide all concealed text.', function() + command('let &conceallevel=3') screen:expect([[ // No Conceal | - | - | - | + |*3 ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*4 | ]]) end) end) -- conceallevel - - describe("cursor movement", function() + describe('cursor movement', function() before_each(function() - command("syn keyword concealy barf conceal cchar=b") - command("set cole=2") + command('syn keyword concealy barf conceal cchar=b') + command('set cole=2') feed('5Ofoo barf bar barf eggs<esc>') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 foo barf bar barf egg^s | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) - end) it('between windows', function() feed('k') - command("split") + command('split') screen:expect([[ foo {1:b} bar {1:b} eggs | foo barf bar barf egg^s | foo {1:b} bar {1:b} eggs | | {2:[No Name] [+] }| - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 {3:[No Name] [+] }| | ]]) feed('<c-w>w') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 | {3:[No Name] [+] }| foo {1:b} bar {1:b} eggs | @@ -423,29 +323,20 @@ describe('Screen', function() it('in insert mode', function() feed('i') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 foo barf bar barf egg^s | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('<up>') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*3 foo barf bar barf egg^s | foo {1:b} bar {1:b} eggs | | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) end) @@ -455,73 +346,47 @@ describe('Screen', function() feed('gg') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('i') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('<esc>') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('v') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- VISUAL --} | ]]) feed('<esc>') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) - end) it('between modes cocu=n', function() @@ -529,71 +394,45 @@ describe('Screen', function() feed('gg') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) feed('i') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- INSERT --} | ]]) feed('<esc>') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) - feed('v') screen:expect([[ ^foo barf bar barf eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 {4:-- VISUAL --} | ]]) feed('<esc>') screen:expect([[ ^foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*4 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -601,15 +440,10 @@ describe('Screen', function() it('and open line', function() feed('o') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 ^ | | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:-- INSERT --} | ]]) end) @@ -618,15 +452,10 @@ describe('Screen', function() command('set cocu=i') feed('o') screen:expect([[ - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 ^ | | - {0:~ }| - {0:~ }| + {0:~ }|*2 {4:-- INSERT --} | ]]) end) @@ -639,12 +468,9 @@ describe('Screen', function() ^foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -655,12 +481,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -669,12 +492,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo barf bar barf eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -683,12 +503,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo barf bar barf eggs {3:xy} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /xy^ | ]]) @@ -697,12 +514,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) end) @@ -717,12 +531,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -731,12 +542,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -745,12 +553,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs {3:xy} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /xy^ | ]]) @@ -759,12 +564,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -773,12 +575,9 @@ describe('Screen', function() ^foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -789,12 +588,9 @@ describe('Screen', function() ^foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) @@ -805,12 +601,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -819,12 +612,9 @@ describe('Screen', function() foo {1:b} bar {1:b} eggs | foo barf bar barf eggs {3:x} | foo {1:b} bar {1:b} eggs {5:x}y | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /x^ | ]]) @@ -833,12 +623,9 @@ describe('Screen', function() foo barf bar barf eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 /^ | ]]) @@ -847,12 +634,9 @@ describe('Screen', function() ^foo {1:b} bar {1:b} eggs | foo {1:b} bar {1:b} eggs x | foo {1:b} bar {1:b} eggs xy | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | ]]) end) @@ -863,44 +647,33 @@ describe('Screen', function() feed('10Ofoo barf bar barf eggs<esc>') feed(':3<cr>o a<Esc>ggV') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 a | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | - ]]} + ]], + } feed(string.rep('j', 15)) - screen:expect{grid=[[ - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | - {6:foo }{1:b}{6: bar }{1:b}{6: eggs} | + screen:expect { + grid = [[ + {6:foo }{1:b}{6: bar }{1:b}{6: eggs} |*8 ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | {4:-- VISUAL LINE --} | - ]]} + ]], + } feed(string.rep('k', 15)) - screen:expect{grid=[[ + screen:expect { + grid = [[ ^f{6:oo }{1:b}{6: bar }{1:b}{6: eggs} | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*2 a | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | - foo {1:b} bar {1:b} eggs | + foo {1:b} bar {1:b} eggs |*5 {4:-- VISUAL LINE --} | - ]]} + ]], + } end) end) @@ -913,41 +686,37 @@ describe('Screen', function() bbb ccc ]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ccc | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | - ]]} + ]], + } -- XXX: hack to get notifications, and check only a single line is -- updated. Could use next_msg() also. local orig_handle_grid_line = screen._handle_grid_line local grid_lines = {} function screen._handle_grid_line(self, grid, row, col, items) - table.insert(grid_lines, {row, col, items}) + table.insert(grid_lines, { row, col, items }) orig_handle_grid_line(self, grid, row, col, items) end feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ^ccc | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | - ]]} - eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}, {3, 0, {{' ', 0, 53}}}}, grid_lines) + ]], + } + eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } }, { 3, 0, { { ' ', 0, 53 } } } }, grid_lines) end) it('K_EVENT should not cause extra redraws with concealcursor #13196', function() @@ -960,43 +729,39 @@ describe('Screen', function() bbb ccc ]]) - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ccc | ^ | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | - ]]} + ]], + } -- XXX: hack to get notifications, and check only a single line is -- updated. Could use next_msg() also. local orig_handle_grid_line = screen._handle_grid_line local grid_lines = {} function screen._handle_grid_line(self, grid, row, col, items) - table.insert(grid_lines, {row, col, items}) + table.insert(grid_lines, { row, col, items }) orig_handle_grid_line(self, grid, row, col, items) end feed('k') - screen:expect{grid=[[ + screen:expect { + grid = [[ aaa | bbb | ^ccc | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*5 | - ]]} - eq({{2, 0, {{'c', 0, 3}, {' ', 0, 50}}}}, grid_lines) + ]], + } + eq({ { 2, 0, { { 'c', 0, 3 }, { ' ', 0, 50 } } } }, grid_lines) grid_lines = {} - poke_eventloop() -- causes K_EVENT key + poke_eventloop() -- causes K_EVENT key screen:expect_unchanged() eq({}, grid_lines) -- no redraw was done end) @@ -1015,7 +780,8 @@ describe('Screen', function() command('set nomodified') command('so') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^3split | let m matchadd('Conceal', '') | setl conceallevel2 concealcursornc | @@ -1026,16 +792,18 @@ describe('Screen', function() normal gg | {3:Xcolesearch }| | - ]]} + ]], + } -- Jump to something that is beyond the bottom of the window, -- so there's a scroll down. - feed("/expr<CR>") + feed('/expr<CR>') -- Are the concealed parts of the current line really hidden? -- Is the window's cursor column properly updated for hidden -- parts of the current line? - screen:expect{grid=[[ + screen:expect { + grid = [[ setl conceallevel2 concealcursornc | normal gg | "{5:^expr} | @@ -1046,7 +814,8 @@ describe('Screen', function() normal gg | {3:Xcolesearch }| /expr | - ]]} + ]], + } end) -- oldtest: Test_cursor_column_in_concealed_line_after_leftcol_change() @@ -1064,18 +833,14 @@ describe('Screen', function() -- Are the concealed parts of the current line really hidden? -- Is the window's cursor column properly updated for conceal? - screen:expect{grid=[[ + screen:expect { + grid = [[ ^c | | - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*7 | - ]]} + ]], + } end) end) end) diff --git a/test/functional/ui/tabline_spec.lua b/test/functional/ui/tabline_spec.lua index befdb7c5d1..1c90b17e57 100644 --- a/test/functional/ui/tabline_spec.lua +++ b/test/functional/ui/tabline_spec.lua @@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, command, eq = helpers.clear, helpers.command, helpers.eq local insert = helpers.insert -local meths = helpers.meths +local api = helpers.api local assert_alive = helpers.assert_alive describe('ui/ext_tabline', function() @@ -12,7 +12,7 @@ describe('ui/ext_tabline', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach({rgb=true, ext_tabline=true}) + screen:attach({ rgb = true, ext_tabline = true }) function screen:_handle_tabline_update(curtab, tabs, curbuf, buffers) event_curtab = curtab event_tabs = tabs @@ -22,73 +22,77 @@ describe('ui/ext_tabline', function() end) it('publishes UI events', function() - command("tabedit another-tab") + command('tabedit another-tab') local expected_tabs = { - {tab = { id = 1 }, name = '[No Name]'}, - {tab = { id = 2 }, name = 'another-tab'}, + { tab = 1, name = '[No Name]' }, + { tab = 2, name = 'another-tab' }, } - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 | - ]], condition=function() - eq({ id = 2 }, event_curtab) - eq(expected_tabs, event_tabs) - end} + ]], + condition = function() + eq(2, event_curtab) + eq(expected_tabs, event_tabs) + end, + } - command("tabNext") - screen:expect{grid=[[ + command('tabNext') + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 | - ]], condition=function() - eq({ id = 1 }, event_curtab) - eq(expected_tabs, event_tabs) - end} + ]], + condition = function() + eq(1, event_curtab) + eq(expected_tabs, event_tabs) + end, + } end) it('buffer UI events', function() - local expected_buffers_initial= { - {buffer = { id = 1 }, name = '[No Name]'}, + local expected_buffers_initial = { + { buffer = 1, name = '[No Name]' }, } - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 | - ]], condition=function() - eq({ id = 1}, event_curbuf) - eq(expected_buffers_initial, event_buffers) - end} + ]], + condition = function() + eq(1, event_curbuf) + eq(expected_buffers_initial, event_buffers) + end, + } - command("badd another-buffer") - command("bnext") + command('badd another-buffer') + command('bnext') local expected_buffers = { - {buffer = { id = 1 }, name = '[No Name]'}, - {buffer = { id = 2 }, name = 'another-buffer'}, + { buffer = 1, name = '[No Name]' }, + { buffer = 2, name = 'another-buffer' }, } - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - ~ | - ~ | - ~ | + ~ |*3 | - ]], condition=function() - eq({ id = 2 }, event_curbuf) - eq(expected_buffers, event_buffers) - end} + ]], + condition = function() + eq(2, event_curbuf) + eq(expected_buffers, event_buffers) + end, + } end) end) -describe("tabline", function() +describe('tabline', function() local screen before_each(function() @@ -96,29 +100,31 @@ describe("tabline", function() screen = Screen.new(42, 5) screen:attach() screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText - [1] = {reverse = true}; -- TabLineFill + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { reverse = true }, -- TabLineFill }) end) it('redraws when tabline option is set', function() command('set tabline=asdf') command('set showtabline=2') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1:asdf }| ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} + ]], + } command('set tabline=jkl') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1:jkl }| ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} + ]], + } end) it('click definitions do not leak memory #21765', function() @@ -132,46 +138,64 @@ describe("tabline", function() command('tabnew') insert('tab2') command('tabprev') - meths.set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {}) - screen:expect{grid=[[ + api.nvim_set_option_value('tabline', '%1T口口%2Ta' .. ('b'):rep(38) .. '%999Xc', {}) + screen:expect { + grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| tab^1 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} + ]], + } assert_alive() - meths.input_mouse('left', 'press', '', 0, 0, 1) - screen:expect{grid=[[ + api.nvim_input_mouse('left', 'press', '', 0, 0, 1) + screen:expect { + grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| tab^2 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} - meths.input_mouse('left', 'press', '', 0, 0, 0) - screen:expect{grid=[[ + ]], + } + api.nvim_input_mouse('left', 'press', '', 0, 0, 0) + screen:expect { + grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| tab^1 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} - meths.input_mouse('left', 'press', '', 0, 0, 39) - screen:expect{grid=[[ + ]], + } + api.nvim_input_mouse('left', 'press', '', 0, 0, 39) + screen:expect { + grid = [[ {1:<abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc }| tab^2 | - {0:~ }| - {0:~ }| + {0:~ }|*2 | - ]]} - meths.input_mouse('left', 'press', '', 0, 0, 40) - screen:expect{grid=[[ + ]], + } + api.nvim_input_mouse('left', 'press', '', 0, 0, 40) + screen:expect { + grid = [[ tab^1 | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | - ]]} + ]], + } + end) + + it('middle-click closes tab', function() + command('tabnew') + command('tabnew') + command('tabnew') + command('tabprev') + eq({ 3, 4 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]')) + api.nvim_input_mouse('middle', 'press', '', 0, 0, 1) + eq({ 2, 3 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]')) + api.nvim_input_mouse('middle', 'press', '', 0, 0, 20) + eq({ 2, 2 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]')) + api.nvim_input_mouse('middle', 'press', '', 0, 0, 1) + eq({ 1, 1 }, api.nvim_eval('[tabpagenr(), tabpagenr("$")]')) end) end) diff --git a/test/functional/ui/title_spec.lua b/test/functional/ui/title_spec.lua index 66c0ff5c9c..8060d3a460 100644 --- a/test/functional/ui/title_spec.lua +++ b/test/functional/ui/title_spec.lua @@ -2,12 +2,12 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command -local curwin = helpers.curwin +local curwin = helpers.api.nvim_get_current_win local eq = helpers.eq local exec_lua = helpers.exec_lua local feed = helpers.feed -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local is_os = helpers.is_os describe('title', function() @@ -43,13 +43,13 @@ describe('title', function() local buf2 before_each(function() - command('edit '..file1) - buf2 = funcs.bufadd(file2) + command('edit ' .. file1) + buf2 = fn.bufadd(file2) command('set title') end) it('calling setbufvar() to set an option in a hidden buffer from i_CTRL-R', function() - command([[inoremap <F2> <C-R>=setbufvar(]]..buf2..[[, '&autoindent', 1) ?? ''<CR>]]) + command([[inoremap <F2> <C-R>=setbufvar(]] .. buf2 .. [[, '&autoindent', 1) ?? ''<CR>]]) feed('i<F2><Esc>') command('redraw!') screen:expect(function() @@ -58,7 +58,7 @@ describe('title', function() end) it('an RPC call to nvim_set_option_value in a hidden buffer', function() - meths.set_option_value('autoindent', true, { buf = buf2 }) + api.nvim_set_option_value('autoindent', true, { buf = buf2 }) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -66,11 +66,14 @@ describe('title', function() end) it('a Lua callback calling nvim_set_option_value in a hidden buffer', function() - exec_lua(string.format([[ + exec_lua(string.format( + [[ vim.schedule(function() vim.api.nvim_set_option_value('autoindent', true, { buf = %d }) end) - ]], buf2)) + ]], + buf2 + )) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -78,11 +81,14 @@ describe('title', function() end) it('a Lua callback calling nvim_buf_call in a hidden buffer', function() - exec_lua(string.format([[ + exec_lua(string.format( + [[ vim.schedule(function() vim.api.nvim_buf_call(%d, function() end) end) - ]], buf2)) + ]], + buf2 + )) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -90,9 +96,9 @@ describe('title', function() end) it('setting the buffer of another window using RPC', function() - local oldwin = curwin().id + local oldwin = curwin() command('split') - meths.win_set_buf(oldwin, buf2) + api.nvim_win_set_buf(oldwin, buf2) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -100,13 +106,17 @@ describe('title', function() end) it('setting the buffer of another window using Lua callback', function() - local oldwin = curwin().id + local oldwin = curwin() command('split') - exec_lua(string.format([[ + exec_lua(string.format( + [[ vim.schedule(function() vim.api.nvim_win_set_buf(%d, %d) end) - ]], oldwin, buf2)) + ]], + oldwin, + buf2 + )) command('redraw!') screen:expect(function() eq(expected, screen.title) @@ -114,8 +124,12 @@ describe('title', function() end) it('creating a floating window using RPC', function() - meths.open_win(buf2, false, { - relative = 'editor', width = 5, height = 5, row = 0, col = 0, + api.nvim_open_win(buf2, false, { + relative = 'editor', + width = 5, + height = 5, + row = 0, + col = 0, }) command('redraw!') screen:expect(function() @@ -124,11 +138,14 @@ describe('title', function() end) it('creating a floating window using Lua callback', function() - exec_lua(string.format([[ + exec_lua(string.format( + [[ vim.api.nvim_open_win(%d, false, { relative = 'editor', width = 5, height = 5, row = 0, col = 0, }) - ]], buf2)) + ]], + buf2 + )) command('redraw!') screen:expect(function() eq(expected, screen.title) diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 3201135b67..667dd64d62 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -1,8 +1,8 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, command = helpers.clear, helpers.feed, helpers.command -local funcs = helpers.funcs -local meths = helpers.meths +local fn = helpers.fn +local api = helpers.api local eq = helpers.eq local eval = helpers.eval local retry = helpers.retry @@ -20,97 +20,99 @@ describe("'wildmenu'", function() -- oldtest: Test_wildmenu_screendump() it('works', function() screen:set_default_attr_ids({ - [0] = {bold = true, foreground = Screen.colors.Blue}; -- NonText - [1] = {foreground = Screen.colors.Black, background = Screen.colors.Yellow}; -- WildMenu - [2] = {bold = true, reverse = true}; -- StatusLine + [0] = { bold = true, foreground = Screen.colors.Blue }, -- NonText + [1] = { foreground = Screen.colors.Black, background = Screen.colors.Yellow }, -- WildMenu + [2] = { bold = true, reverse = true }, -- StatusLine }) -- Test simple wildmenu feed(':sign <Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {1:define}{2: jump list > }| :sign define^ | - ]]} + ]], + } feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define }{1:jump}{2: list > }| :sign jump^ | - ]]} + ]], + } feed('<Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define jump }{1:list}{2: > }| :sign list^ | - ]]} + ]], + } -- Looped back to the original value feed('<Tab><Tab><Tab><Tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:define jump list > }| :sign ^ | - ]]} + ]], + } -- Test that the wild menu is cleared properly feed('<Space>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 :sign ^ | - ]]} + ]], + } -- Test that a different wildchar still works feed('<Esc>') command('set wildchar=<Esc>') feed(':sign <Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {1:define}{2: jump list > }| :sign define^ | - ]]} + ]], + } -- Double-<Esc> is a hard-coded method to escape while wildchar=<Esc>. Make -- sure clean up is properly done in edge case like this. feed('<Esc>') - screen:expect{grid=[[ + screen:expect { + grid = [[ ^ | - {0:~ }| - {0:~ }| - {0:~ }| + {0:~ }|*3 | - ]]} + ]], + } end) it('C-E to cancel wildmenu completion restore original input', function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<C-E>') screen:expect([[ | - ~ | - ~ | - ~ | + ~ |*3 :sign ^ | ]]) end) @@ -119,17 +121,14 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<tab><C-Y>') screen:expect([[ | - ~ | - ~ | - ~ | + ~ |*3 :sign jump^ | ]]) end) @@ -139,8 +138,7 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) @@ -154,16 +152,14 @@ describe("'wildmenu'", function() feed(':sign <tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | ]]) feed('<space>') screen:expect([[ | - ~ | - ~ | + ~ |*2 [No Name] | :sign define ^ | ]]) @@ -174,8 +170,7 @@ describe("'wildmenu'", function() feed(':j<Tab><Tab><Tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 join jumps | :j^ | ]]) @@ -183,8 +178,7 @@ describe("'wildmenu'", function() feed('<BS><Tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 ! # & < = > @ > | :!^ | ]]) @@ -194,52 +188,51 @@ describe("'wildmenu'", function() command('set wildmenu wildmode=full') command('set scrollback=4') feed((':terminal "%s" REP 5000 !terminal_output!<cr>'):format(testprg('shell-test'))) - feed('G') -- Follow :terminal output. - feed([[:sign <Tab>]]) -- Invoke wildmenu. + feed('G') -- Follow :terminal output. + feed([[:sign <Tab>]]) -- Invoke wildmenu. -- NB: in earlier versions terminal output was redrawn during cmdline mode. -- For now just assert that the screen remains unchanged. - screen:expect{any='define jump list > |\n:sign define^ |'} + screen:expect { any = 'define jump list > |\n:sign define^ |' } screen:expect_unchanged() -- cmdline CTRL-D display should also be preserved. feed([[<C-U>]]) - feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D. - screen:expect{grid=[[ + feed([[sign <C-D>]]) -- Invoke cmdline CTRL-D. + screen:expect { + grid = [[ :sign | define place | jump undefine | list unplace | :sign ^ | - ]]} + ]], + } screen:expect_unchanged() -- Exiting cmdline should show the buffer. feed([[<C-\><C-N>]]) - screen:expect{any=[[!terminal_output!]]} + screen:expect { any = [[!terminal_output!]] } end) it('ignores :redrawstatus called from a timer #7108', function() command('set wildmenu wildmode=full') command([[call timer_start(10, {->execute('redrawstatus')}, {'repeat':-1})]]) feed([[<C-\><C-N>]]) - feed([[:sign <Tab>]]) -- Invoke wildmenu. - screen:expect{grid=[[ + feed([[:sign <Tab>]]) -- Invoke wildmenu. + screen:expect { + grid = [[ | - ~ | - ~ | + ~ |*2 define jump list > | :sign define^ | - ]]} + ]], + } screen:expect_unchanged() end) it('with laststatus=0, :vsplit, :term #2255', function() - -- Because this test verifies a _lack_ of activity after screen:sleep(), we - -- must wait the full timeout. So make it reasonable. - screen.timeout = 1000 - if not is_os('win') then - command('set shell=sh') -- Need a predictable "$" prompt. + command('set shell=sh') -- Need a predictable "$" prompt. command('let $PS1 = "$"') end command('set laststatus=0') @@ -256,11 +249,13 @@ describe("'wildmenu'", function() end) feed([[<C-\><C-N>]]) - feed([[:<Tab>]]) -- Invoke wildmenu. + feed([[:<Tab>]]) -- Invoke wildmenu. -- Check only the last 2 lines, because the shell output is -- system-dependent. - screen:expect{any='! # & < = > @ > |\n:!^'} - screen:expect_unchanged() + screen:expect { any = '! # & < = > @ > |\n:!^' } + -- Because this test verifies a _lack_ of activity, we must wait the full timeout. + -- So make it reasonable. + screen:expect_unchanged(false, 1000) end) it('wildmode=list,full and messages interaction #10092', function() @@ -282,21 +277,16 @@ describe("'wildmenu'", function() feed('<tab>') -- trigger wildmode full screen:expect([[ [No Name] | - | - | + |*2 :set wildm | - wildmenu wildmode | - wildmenu wildmode | + wildmenu wildmode |*2 :set wildmenu^ | ]]) feed('<Esc>') screen:expect([[ [No Name] | ^ | - ~ | - ~ | - ~ | - ~ | + ~ |*4 | ]]) end) @@ -311,18 +301,13 @@ describe("'wildmenu'", function() feed(':sign u<tab>') screen:expect([[ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 :sign un^ | ]]) feed('<tab>') -- trigger wildmode list screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign un | undefine unplace | @@ -331,11 +316,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) @@ -343,8 +324,7 @@ describe("'wildmenu'", function() feed(':sign un<tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign un | undefine unplace | @@ -355,11 +335,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) end) @@ -372,8 +348,7 @@ describe("'wildmenu'", function() feed(':sign u<tab>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign u | undefine unplace | @@ -382,8 +357,7 @@ describe("'wildmenu'", function() feed('<tab>') -- trigger wildmode longest screen:expect([[ | - ~ | - ~ | + ~ |*2 | :sign u | undefine unplace | @@ -392,11 +366,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | - ~ | + ~ |*5 | ]]) end) @@ -409,8 +379,7 @@ describe("'wildmenu'", function() feed('<c-d>') screen:expect([[ | - ~ | - ~ | + ~ |*2 | :set wildm | wildmenu wildmode | @@ -418,8 +387,7 @@ describe("'wildmenu'", function() ]]) feed('<c-d>') screen:expect([[ - | - | + |*2 :set wildm | wildmenu wildmode | :set wildm | @@ -429,10 +397,7 @@ describe("'wildmenu'", function() feed('<Esc>') screen:expect([[ ^ | - ~ | - ~ | - ~ | - ~ | + ~ |*4 [No Name] | | ]]) @@ -440,28 +405,29 @@ describe("'wildmenu'", function() it('works with c_CTRL_Z standard mapping', function() screen:set_default_attr_ids { - [1] = {bold = true, foreground = Screen.colors.Blue1}; - [2] = {foreground = Screen.colors.Grey0, background = Screen.colors.Yellow}; - [3] = {bold = true, reverse = true}; + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow }, + [3] = { bold = true, reverse = true }, } -- Wildcharm? where we are going we aint't no need no wildcharm. - eq(0, meths.get_option_value('wildcharm', {})) + eq(0, api.nvim_get_option_value('wildcharm', {})) -- Don't mess the defaults yet (neovim is about backwards compatibility) - eq(9, meths.get_option_value('wildchar', {})) + eq(9, api.nvim_get_option_value('wildchar', {})) -- Lol what is cnoremap? Some say it can define mappings. command 'set wildchar=0' - eq(0, meths.get_option_value('wildchar', {})) + eq(0, api.nvim_get_option_value('wildchar', {})) command 'cnoremap <f2> <c-z>' feed(':syntax <f2>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:case}{3: clear cluster > }| :syntax case^ | - ]]} + ]], + } feed '<esc>' command 'set wildmode=longest:full,full' @@ -469,31 +435,32 @@ describe("'wildmenu'", function() command [[cnoremap <expr> <tab> luaeval("not rawset(_G, 'coin', not coin).coin") ? "<c-z>" : "c"]] feed ':syntax <tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :syntax c^ | - ]]} + ]], + } feed '<tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {3:case clear cluster > }| :syntax c^ | - ]]} + ]], + } feed '<tab>' - screen:expect{grid=[[ + screen:expect { + grid = [[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :syntax cc^ | - ]]} + ]], + } end) end) @@ -503,9 +470,9 @@ describe('command line completion', function() clear() screen = Screen.new(40, 5) screen:set_default_attr_ids({ - [1] = {bold = true, foreground = Screen.colors.Blue1}, - [2] = {foreground = Screen.colors.Grey0, background = Screen.colors.Yellow}, - [3] = {bold = true, reverse = true}, + [1] = { bold = true, foreground = Screen.colors.Blue1 }, + [2] = { foreground = Screen.colors.Grey0, background = Screen.colors.Yellow }, + [3] = { bold = true, reverse = true }, }) screen:attach() end) @@ -514,17 +481,15 @@ describe('command line completion', function() end) it('lists directories with empty PATH', function() - local tmp = funcs.tempname() - command('e '.. tmp) + local tmp = fn.tempname() + command('e ' .. tmp) command('cd %:h') command("call mkdir('Xtest-functional-viml-compl-dir')") command('let $PATH=""') feed(':!<tab><bs>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :!Xtest-functional-viml-compl-dir^ | ]]) end) @@ -535,71 +500,63 @@ describe('command line completion', function() feed(':!echo $XTEST_<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:XTEST_1}{3: XTEST_2 }| :!echo $XTEST_1^ | ]]) end) it('completes (multibyte) env var names #9655', function() - clear({env={ - ['XTEST_1AaあB']='foo', - ['XTEST_2']='bar', - }}) + clear({ env = { + ['XTEST_1AaあB'] = 'foo', + ['XTEST_2'] = 'bar', + } }) screen:attach() command('set wildmenu wildmode=full') feed(':!echo $XTEST_<tab>') screen:expect([[ | - {1:~ }| - {1:~ }| + {1:~ }|*2 {2:XTEST_1AaあB}{3: XTEST_2 }| :!echo $XTEST_1AaあB^ | ]]) end) it('does not leak memory with <S-Tab> with wildmenu and only one match #19874', function() - meths.set_option_value('wildmenu', true, {}) - meths.set_option_value('wildmode', 'full', {}) - meths.set_option_value('wildoptions', 'pum', {}) + api.nvim_set_option_value('wildmenu', true, {}) + api.nvim_set_option_value('wildmode', 'full', {}) + api.nvim_set_option_value('wildoptions', 'pum', {}) feed(':sign unpla<S-Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace^ | ]]) feed('<Space>buff<Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace buffer=^ | ]]) end) it('does not show matches with <S-Tab> without wildmenu with wildmode=full', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'full', {}) + api.nvim_set_option_value('wildmenu', false, {}) + api.nvim_set_option_value('wildmode', 'full', {}) feed(':sign <S-Tab>') screen:expect([[ | - {1:~ }| - {1:~ }| - {1:~ }| + {1:~ }|*3 :sign unplace^ | ]]) end) it('shows matches with <S-Tab> without wildmenu with wildmode=list', function() - meths.set_option_value('wildmenu', false, {}) - meths.set_option_value('wildmode', 'list', {}) + api.nvim_set_option_value('wildmenu', false, {}) + api.nvim_set_option_value('wildmode', 'list', {}) feed(':sign <S-Tab>') screen:expect([[ @@ -618,64 +575,72 @@ describe('ui/ext_wildmenu', function() before_each(function() clear() screen = Screen.new(25, 5) - screen:attach({rgb=true, ext_wildmenu=true}) + screen:attach({ rgb = true, ext_wildmenu = true }) end) it('works with :sign <tab>', function() local expected = { - 'define', - 'jump', - 'list', - 'place', - 'undefine', - 'unplace', + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', } command('set wildmode=full') command('set wildmenu') feed(':sign <tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign define^ | - ]], wildmenu_items=expected, wildmenu_pos=0} + ]], + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('<tab>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign jump^ | - ]], wildmenu_items=expected, wildmenu_pos=1} + ]], + wildmenu_items = expected, + wildmenu_pos = 1, + } feed('<left><left>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign ^ | - ]], wildmenu_items=expected, wildmenu_pos=-1} + ]], + wildmenu_items = expected, + wildmenu_pos = -1, + } feed('<right>') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign define^ | - ]], wildmenu_items=expected, wildmenu_pos=0} + ]], + wildmenu_items = expected, + wildmenu_pos = 0, + } feed('a') - screen:expect{grid=[[ + screen:expect { + grid = [[ | - ~ | - ~ | - ~ | + ~ |*3 :sign definea^ | - ]]} + ]], + } end) end) diff --git a/test/functional/ui/winbar_spec.lua b/test/functional/ui/winbar_spec.lua index 78bbcd3a63..c2a52c0f21 100644 --- a/test/functional/ui/winbar_spec.lua +++ b/test/functional/ui/winbar_spec.lua @@ -3,12 +3,11 @@ local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command local insert = helpers.insert -local meths = helpers.meths +local api = helpers.api local eq = helpers.eq local poke_eventloop = helpers.poke_eventloop local feed = helpers.feed -local funcs = helpers.funcs -local curwin = helpers.curwin +local fn = helpers.fn local pcall_err = helpers.pcall_err describe('winbar', function() @@ -19,59 +18,50 @@ describe('winbar', function() screen = Screen.new(60, 13) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true}, - [2] = {reverse = true}, - [3] = {bold = true, foreground = Screen.colors.Blue}, - [4] = {bold = true, reverse = true}, - [5] = {bold = true, foreground = Screen.colors.Red}, - [6] = {foreground = Screen.colors.Blue}, - [7] = {background = Screen.colors.LightGrey}, - [8] = {background = Screen.colors.LightMagenta}, - [9] = {bold = true, foreground = Screen.colors.Blue, background = Screen.colors.LightMagenta}, - [10] = {background = Screen.colors.LightGrey, underline = true}, - [11] = {background = Screen.colors.LightGrey, underline = true, bold = true, foreground = Screen.colors.Magenta}, + [1] = { bold = true }, + [2] = { reverse = true }, + [3] = { bold = true, foreground = Screen.colors.Blue }, + [4] = { bold = true, reverse = true }, + [5] = { bold = true, foreground = Screen.colors.Red }, + [6] = { foreground = Screen.colors.Blue }, + [7] = { foreground = Screen.colors.Black, background = Screen.colors.LightGrey }, + [8] = { background = Screen.colors.LightMagenta }, + [9] = { + bold = true, + foreground = Screen.colors.Blue, + background = Screen.colors.LightMagenta, + }, + [10] = { background = Screen.colors.LightGrey, underline = true }, + [11] = { + background = Screen.colors.LightGrey, + underline = true, + bold = true, + foreground = Screen.colors.Magenta, + }, }) - meths.set_option_value('winbar', 'Set Up The Bars', {}) + api.nvim_set_option_value('winbar', 'Set Up The Bars', {}) end) it('works', function() screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*10 | ]]) -- winbar is excluded from the heights returned by winheight() and getwininfo() - eq(11, funcs.winheight(0)) - local win_info = funcs.getwininfo(curwin().id)[1] + eq(11, fn.winheight(0)) + local win_info = fn.getwininfo(api.nvim_get_current_win())[1] eq(11, win_info.height) eq(1, win_info.winbar) end) - it('works with custom \'fillchars\' value', function() + it("works with custom 'fillchars' value", function() command('set fillchars=wbr:+') screen:expect([[ {1:Set Up The Bars+++++++++++++++++++++++++++++++++++++++++++++}| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*10 | ]]) end) @@ -81,16 +71,7 @@ describe('winbar', function() screen:expect([[ {5:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*10 | ]]) end) @@ -151,20 +132,17 @@ describe('winbar', function() ]]) end) - it('works when switching value of \'winbar\'', function() + it("works when switching value of 'winbar'", function() command('belowright vsplit | split | split | set winbar=') screen:expect([[ │^ | - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {3:~ }│{4:[No Name] }| {3:~ }│ | - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {3:~ }│{2:[No Name] }| {3:~ }│ | - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {2:[No Name] [No Name] }| | ]]) @@ -206,54 +184,36 @@ describe('winbar', function() insert [[ just some random text]] - meths.set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {}) - screen:expect{grid=[[ + api.nvim_set_option_value('winbar', 'Hello, I am a ruler: %l,%c', {}) + screen:expect { + grid = [[ {1:Hello, I am a ruler: 2,11 }| just some | random tex^t | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*9 | - ]]} + ]], + } feed 'b' - screen:expect{grid=[[ + screen:expect { + grid = [[ {1:Hello, I am a ruler: 2,8 }| just some | random ^text | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*9 | - ]]} + ]], + } feed 'k' - screen:expect{grid=[[ + screen:expect { + grid = [[ {1:Hello, I am a ruler: 1,8 }| just so^me | random text | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*9 | - ]]} + ]], + } end) it('works with laststatus=3', function() @@ -261,15 +221,7 @@ describe('winbar', function() screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*9 {4:[No Name] }| | ]]) @@ -295,14 +247,7 @@ describe('winbar', function() {10: }{11:4}{10: [No Name] }{1: [No Name] }{2: }{10:X}| {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*8 {4:[No Name] }| | ]]) @@ -319,7 +264,7 @@ describe('winbar', function() line sin(theta) line 8]]) - meths.input_mouse('left', 'press', '', 0, 5, 1) + api.nvim_input_mouse('left', 'press', '', 0, 5, 1) screen:expect([[ {1:Set Up The Bars }| line 1 | @@ -330,14 +275,12 @@ describe('winbar', function() line i | line sin(theta) | line 8 | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 | ]]) - eq({5, 1}, meths.win_get_cursor(0)) + eq({ 5, 1 }, api.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 6, 2) + api.nvim_input_mouse('left', 'drag', '', 0, 6, 2) screen:expect([[ {1:Set Up The Bars }| line 1 | @@ -348,14 +291,12 @@ describe('winbar', function() {7:li}^ne i | line sin(theta) | line 8 | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 {1:-- VISUAL --} | ]]) - eq({6, 2}, meths.win_get_cursor(0)) + eq({ 6, 2 }, api.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 1, 2) + api.nvim_input_mouse('left', 'drag', '', 0, 1, 2) screen:expect([[ {1:Set Up The Bars }| li^n{7:e 1} | @@ -366,16 +307,14 @@ describe('winbar', function() line i | line sin(theta) | line 8 | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 {1:-- VISUAL --} | ]]) - eq({1, 2}, meths.win_get_cursor(0)) + eq({ 1, 2 }, api.nvim_win_get_cursor(0)) - meths.input_mouse('left', 'drag', '', 0, 0, 2) + api.nvim_input_mouse('left', 'drag', '', 0, 0, 2) screen:expect_unchanged() - eq({1, 2}, meths.win_get_cursor(0)) + eq({ 1, 2 }, api.nvim_win_get_cursor(0)) end) it('dragging statusline with mouse works correctly', function() @@ -383,92 +322,72 @@ describe('winbar', function() screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 {4:[No Name] }| {1:Set Up The Bars }| | - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*3 {2:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 1, 5, 10) + api.nvim_input_mouse('left', 'press', '', 1, 5, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 6, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 6, 10) screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 {4:[No Name] }| {1:Set Up The Bars }| | - {3:~ }| - {3:~ }| + {3:~ }|*2 {2:[No Name] }| | ]]) - meths.input_mouse('left', 'drag', '', 1, 4, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 4, 10) screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| + {3:~ }|*2 {4:[No Name] }| {1:Set Up The Bars }| | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 {2:[No Name] }| | ]]) - meths.input_mouse('left', 'press', '', 1, 11, 10) + api.nvim_input_mouse('left', 'press', '', 1, 11, 10) poke_eventloop() - meths.input_mouse('left', 'drag', '', 1, 9, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 9, 10) screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| + {3:~ }|*2 {4:[No Name] }| {1:Set Up The Bars }| | - {3:~ }| - {3:~ }| + {3:~ }|*2 {2:[No Name] }| - | - | - | + |*3 ]]) - eq(3, meths.get_option_value('cmdheight', {})) + eq(3, api.nvim_get_option_value('cmdheight', {})) - meths.input_mouse('left', 'drag', '', 1, 11, 10) + api.nvim_input_mouse('left', 'drag', '', 1, 11, 10) screen:expect([[ {1:Set Up The Bars }| ^ | - {3:~ }| - {3:~ }| + {3:~ }|*2 {4:[No Name] }| {1:Set Up The Bars }| | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 {2:[No Name] }| | ]]) - eq(1, meths.get_option_value('cmdheight', {})) + eq(1, api.nvim_get_option_value('cmdheight', {})) end) it('properly equalizes window height for window-local value', function() @@ -493,40 +412,34 @@ describe('winbar', function() end) it('requires window-local value for floating windows', function() - local win = meths.open_win(0, false, { relative = 'editor', row = 2, col = 10, height = 7, - width = 30 }) - meths.set_option_value('winbar', 'bar', {}) - screen:expect{grid=[[ + local win = api.nvim_open_win( + 0, + false, + { relative = 'editor', row = 2, col = 10, height = 7, width = 30 } + ) + api.nvim_set_option_value('winbar', 'bar', {}) + screen:expect { + grid = [[ {1:bar }| ^ | {3:~ }{8: }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }| - {3:~ }| - {3:~ }| - | - ]]} - meths.set_option_value('winbar', 'floaty bar', { scope = 'local', win = win.id }) - screen:expect{grid=[[ + {3:~ }{9:~ }{3: }|*6 + {3:~ }|*3 + | + ]], + } + api.nvim_set_option_value('winbar', 'floaty bar', { scope = 'local', win = win }) + screen:expect { + grid = [[ {1:bar }| ^ | {3:~ }{1:floaty bar }{3: }| {3:~ }{8: }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }{9:~ }{3: }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }{9:~ }{3: }|*5 + {3:~ }|*3 | - ]]} + ]], + } end) it('works correctly when moving a split', function() @@ -537,8 +450,7 @@ describe('winbar', function() screen:expect([[ {1:foo }│ | ^ │{3:~ }| - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {4:[No Name] }{2:[No Name] }| | ]]) @@ -547,8 +459,7 @@ describe('winbar', function() screen:expect([[ │{1:foo }| {3:~ }│^ | - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {2:[No Name] }{4:[No Name] }| | ]]) @@ -558,8 +469,7 @@ describe('winbar', function() screen:expect([[ {1:foo }│^ | │{3:~ }| - {3:~ }│{3:~ }| - {3:~ }│{3:~ }| + {3:~ }│{3:~ }|*2 {2:[No Name] }{4:[No Name] }| | ]]) @@ -571,14 +481,7 @@ describe('winbar', function() ^ | {4:[No Name] }| | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*8 {2:[No Name] }| | ]]) @@ -589,12 +492,7 @@ describe('winbar', function() {4:[No Name] }| {1:a }| | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*6 {2:[No Name] }| | ]]) @@ -628,12 +526,12 @@ describe('local winbar with tabs', function() screen = Screen.new(60, 10) screen:attach() screen:set_default_attr_ids({ - [1] = {bold = true}, - [2] = {reverse = true}, - [3] = {bold = true, foreground = Screen.colors.Blue}, - [4] = {underline = true, background = Screen.colors.LightGray} + [1] = { bold = true }, + [2] = { reverse = true }, + [3] = { bold = true, foreground = Screen.colors.Blue }, + [4] = { underline = true, background = Screen.colors.LightGray }, }) - meths.set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) + api.nvim_set_option_value('winbar', 'foo', { scope = 'local', win = 0 }) end) it('works', function() @@ -641,28 +539,19 @@ describe('local winbar with tabs', function() screen:expect([[ {4: [No Name] }{1: [No Name] }{2: }{4:X}| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*7 | ]]) command('tabnext') - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: [No Name] }{4: [No Name] }{2: }{4:X}| {1:foo }| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*6 | - ]]} + ]], + } end) it('can edit new empty buffer #19458', function() @@ -670,68 +559,65 @@ describe('local winbar with tabs', function() some goofy text]] - screen:expect{grid=[[ + screen:expect { + grid = [[ {1:foo }| some | goofy | tex^t | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*5 | - ]]} + ]], + } -- this used to throw an E315 ml_get error command 'tabedit' - screen:expect{grid=[[ + screen:expect { + grid = [[ {4: + [No Name] }{1: [No Name] }{2: }{4:X}| ^ | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*7 | - ]]} + ]], + } command 'tabprev' - screen:expect{grid=[[ + screen:expect { + grid = [[ {1: + [No Name] }{4: [No Name] }{2: }{4:X}| {1:foo }| some | goofy | tex^t | - {3:~ }| - {3:~ }| - {3:~ }| - {3:~ }| + {3:~ }|*4 | - ]]} + ]], + } end) end) it('winbar works properly when redrawing is postponed #23534', function() - clear({args = { - '-c', 'set laststatus=2 lazyredraw', - '-c', 'setlocal statusline=(statusline) winbar=(winbar)', - '-c', 'call nvim_input(":<Esc>")', - }}) + clear({ + args = { + '-c', + 'set laststatus=2 lazyredraw', + '-c', + 'setlocal statusline=(statusline) winbar=(winbar)', + '-c', + 'call nvim_input(":<Esc>")', + }, + }) local screen = Screen.new(60, 6) screen:attach() screen:set_default_attr_ids({ - [0] = {foreground = Screen.colors.Blue, bold = true}, - [1] = {bold = true}, - [2] = {bold = true, reverse = true}, + [0] = { foreground = Screen.colors.Blue, bold = true }, + [1] = { bold = true }, + [2] = { bold = true, reverse = true }, }) screen:expect([[ {1:(winbar) }| ^ | - {0:~ }| - {0:~ }| + {0:~ }|*2 {2:(statusline) }| | ]]) |