diff options
Diffstat (limited to 'test/functional/ui')
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 243 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 200 | ||||
-rw-r--r-- | test/functional/ui/input_spec.lua | 38 |
3 files changed, 409 insertions, 72 deletions
diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 7a87521a6b..6cf549909a 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -8,6 +8,7 @@ local exec_lua = helpers.exec_lua local exec = helpers.exec local expect_events = helpers.expect_events local meths = helpers.meths +local command = helpers.command describe('decorations providers', function() local screen @@ -314,11 +315,30 @@ describe('extmark decorations', function() [2] = {foreground = Screen.colors.Brown}; [3] = {bold = true, foreground = Screen.colors.SeaGreen}; [4] = {background = Screen.colors.Red1, foreground = Screen.colors.Gray100}; + [5] = {foreground = Screen.colors.Brown, bold = true}; + [6] = {foreground = Screen.colors.DarkCyan}; + [7] = {foreground = Screen.colors.Grey0, background = tonumber('0xff4c4c')}; + [8] = {foreground = tonumber('0x180606'), background = tonumber('0xff4c4c')}; + [9] = {foreground = tonumber('0xe40c0c'), background = tonumber('0xff4c4c'), bold = true}; + [10] = {foreground = tonumber('0xb20000'), background = tonumber('0xff4c4c')}; + [11] = {blend = 30, background = Screen.colors.Red1}; + [12] = {foreground = Screen.colors.Brown, blend = 30, background = Screen.colors.Red1, bold = true}; + [13] = {foreground = Screen.colors.Fuchsia}; + [14] = {background = Screen.colors.Red1, foreground = Screen.colors.Black}; + [15] = {background = Screen.colors.Red1, foreground = tonumber('0xb20000')}; + [16] = {blend = 30, background = Screen.colors.Red1, foreground = Screen.colors.Magenta1}; + [17] = {bold = true, foreground = Screen.colors.Brown, background = Screen.colors.LightGrey}; + [18] = {background = Screen.colors.LightGrey}; + [19] = {foreground = Screen.colors.Cyan4, background = Screen.colors.LightGrey}; + [20] = {foreground = tonumber('0x180606'), background = tonumber('0xf13f3f')}; + [21] = {foreground = Screen.colors.Gray0, background = tonumber('0xf13f3f')}; + [22] = {foreground = tonumber('0xb20000'), background = tonumber('0xf13f3f')}; + [23] = {foreground = Screen.colors.Magenta1, background = Screen.colors.LightGrey}; + [24] = {bold = true}; } end) - it('can have virtual text of overlay style', function() - insert [[ + local example_text = [[ for _,item in ipairs(items) do local text, hl_id_cell, count = unpack(item) if hl_id_cell ~= nil then @@ -331,69 +351,164 @@ for _,item in ipairs(items) do colpos = colpos+1 end end]] - feed 'gg' - local ns = meths.create_namespace 'test' - for i = 1,9 do - meths.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'}) + it('can have virtual text of overlay position', function() + insert(example_text) + feed 'gg' + + local ns = meths.create_namespace 'test' + for i = 1,9 do + meths.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'}) + end end - end - meths.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'}) - -- bound check: right edge of window - meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork ' }, {'bork bork bork', 'ErrorMsg'}}, virt_text_pos='overlay'}) - - screen:expect{grid=[[ - ^for _,item in ipairs(items) do | - {2:|} local text, hl_id_cell, count = unpack(item) | - {2:|} if hl_id_cell ~= nil tbork bork bork {4:bork bork}| - {2:|} {1:|} hl_id = hl_id_cell | - {2:|} end | - {2:|} for _ = 1, (count or 1) {4:loopy} | - {2:|} {1:|} local cell = line[colpos] | - {2:|} {1:|} cell.text = text | - {2:|} {1:|} cell.hl_id = hl_id | - {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | - end | - end | - {1:~ }| - {1:~ }| - | - ]]} - - - -- handles broken lines - screen:try_resize(22, 25) - screen:expect{grid=[[ - ^for _,item in ipairs(i| - tems) do | - {2:|} local text, hl_id_| - cell, count = unpack(i| - tem) | - {2:|} if hl_id_cell ~= n| - il tbork bork bork {4:bor}| - {2:|} {1:|} hl_id = hl_id_| - cell | - {2:|} end | - {2:|} for _ = 1, (count | - or 1) {4:loopy} | - {2:|} {1:|} local cell = l| - ine[colpos] | - {2:|} {1:|} cell.text = te| - xt | - {2:|} {1:|} cell.hl_id = h| - l_id | - {2:|} {1:|} cofoo{3:bar}{4:!!}olpo| - s+1 | - end | - end | - {1:~ }| - {1:~ }| - | - ]]} + meths.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'}) + -- bound check: right edge of window + meths.buf_set_extmark(0, ns, 2, 26, { virt_text={{'bork bork bork ' }, {'bork bork bork', 'ErrorMsg'}}, virt_text_pos='overlay'}) + + screen:expect{grid=[[ + ^for _,item in ipairs(items) do | + {2:|} local text, hl_id_cell, count = unpack(item) | + {2:|} if hl_id_cell ~= nil tbork bork bork {4:bork bork}| + {2:|} {1:|} hl_id = hl_id_cell | + {2:|} end | + {2:|} for _ = 1, (count or 1) {4:loopy} | + {2:|} {1:|} local cell = line[colpos] | + {2:|} {1:|} cell.text = text | + {2:|} {1:|} cell.hl_id = hl_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpos+1 | + end | + end | + {1:~ }| + {1:~ }| + | + ]]} + + + -- handles broken lines + screen:try_resize(22, 25) + screen:expect{grid=[[ + ^for _,item in ipairs(i| + tems) do | + {2:|} local text, hl_id_| + cell, count = unpack(i| + tem) | + {2:|} if hl_id_cell ~= n| + il tbork bork bork {4:bor}| + {2:|} {1:|} hl_id = hl_id_| + cell | + {2:|} end | + {2:|} for _ = 1, (count | + or 1) {4:loopy} | + {2:|} {1:|} local cell = l| + ine[colpos] | + {2:|} {1:|} cell.text = te| + xt | + {2:|} {1:|} cell.hl_id = h| + l_id | + {2:|} {1:|} cofoo{3:bar}{4:!!}olpo| + s+1 | + end | + end | + {1:~ }| + {1:~ }| + | + ]]} + end) + + it('can have virtual text of overlay position and styling', function() + insert(example_text) + feed 'gg' + local ns = meths.create_namespace 'test' + + command 'set ft=lua' + command 'syntax on' + + screen:expect{grid=[[ + {5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | + {5:local} text, hl_id_cell, count = unpack(item) | + {5:if} hl_id_cell ~= {13:nil} {5:then} | + hl_id = hl_id_cell | + {5:end} | + {5:for} _ = {13:1}, (count {5:or} {13:1}) {5:do} | + {5:local} cell = line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+{13:1} | + {5:end} | + {5:end} | + {1:~ }| + {1:~ }| + | + ]]} + + 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'}) + + 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}) + + screen:expect{grid=[[ + {5:^for} _,item {5:in} {6:ipairs}(items) {5:do} | + {5:l}{8:blen}{7:dy}{10:e}{7:text}{10:h}{7:-}{10:_}{7:here}ell, count = unpack(item) | + {5:i}{12:c}{11:ombining color} {13:nil} {5:then} | + {11:replacing color}d_cell | + {5:e}{8:bl}{14:endy}{15:i}{14:text}{15:o}{14:-}{15:o}{14:h}{7:ere} | + {5:f}{12:co}{11:mbini}{16:n}{11:g color}t {5:or} {13:1}) {5:do} | + {11:replacing color} line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+{13:1} | + {5:end} | + {5:end} | + {1:~ }| + {1:~ }| + | + ]]} + + feed 'V5G' + screen:expect{grid=[[ + {17:for}{18: _,item }{17:in}{18: }{19:ipairs}{18:(items) }{17:do} | + {18: }{17:l}{20:blen}{21:dy}{22:e}{21:text}{22:h}{21:-}{22:_}{21:here}{18:ell, count = unpack(item)} | + {18: }{17:i}{12:c}{11:ombining color}{18: }{23:nil}{18: }{17:then} | + {18: }{11:replacing color}{18:d_cell} | + {18: }{5:^e}{17:nd} | + {5:f}{12:co}{11:mbini}{16:n}{11:g color}t {5:or} {13:1}) {5:do} | + {11:replacing color} line[colpos] | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+{13:1} | + {5:end} | + {5:end} | + {1:~ }| + {1:~ }| + {24:-- VISUAL LINE --} | + ]]} + + feed 'jj' + screen:expect{grid=[[ + {17:for}{18: _,item }{17:in}{18: }{19:ipairs}{18:(items) }{17:do} | + {18: }{17:l}{20:blen}{21:dy}{22:e}{21:text}{22:h}{21:-}{22:_}{21:here}{18:ell, count = unpack(item)} | + {18: }{17:i}{12:c}{11:ombining color}{18: }{23:nil}{18: }{17:then} | + {18: }{11:replacing color}{18:d_cell} | + {18: }{17:end} | + {18: }{17:for}{18: _ = }{23:1}{18:, (count }{17:or}{18: }{23:1}{18:) }{17:do} | + {18: }^ {18: }{17:local}{18: cell = line[colpos]} | + cell.text = text | + cell.hl_id = hl_id | + colpos = colpos+{13:1} | + {5:end} | + {5:end} | + {1:~ }| + {1:~ }| + {24:-- VISUAL LINE --} | + ]]} end) end) diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index d3b1d33956..8883ad8270 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -464,6 +464,206 @@ describe("folded lines", function() end end) + it("works with vsplit", function() + insert([[ + aa + bb + cc + dd + ee + ff]]) + feed_command('2') + command("set foldcolumn=1") + feed('zf3j') + feed_command('1') + feed('zf2j') + feed('zO') + feed_command("rightbelow vnew") + insert([[ + aa + bb + cc + dd + ee + ff]]) + feed_command('2') + command("set foldcolumn=1") + feed('zf3j') + feed_command('1') + feed('zf2j') + if multigrid then + meths.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:[No Name] [+] }{3:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + {7:-}aa | + {7:-}bb | + {7:2}cc | + {7:2}dd | + {7:2}ee | + {7:│}ff | + ## grid 3 + :1 | + ## grid 4 + {7:-}^aa | + {7:+}{5:+--- 4 lines: bb····}| + {7:│}ff | + {1:~ }| + {1:~ }| + {1:~ }| + ]]) + else + meths.input_mouse('left', 'press', '', 0, 0, 23) + screen:expect([[ + {7:-}aa {2:│}{7:-}^aa | + {7:-}bb {2:│}{7:+}{5:+--- 4 lines: bb····}| + {7:2}cc {2:│}{7:│}ff | + {7:2}dd {2:│}{1:~ }| + {7:2}ee {2:│}{1:~ }| + {7:│}ff {2:│}{1:~ }| + {2:[No Name] [+] }{3:[No Name] [+] }| + :1 | + ]]) + end + + if multigrid then + meths.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:[No Name] [+] }{3:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + {7:-}aa | + {7:-}bb | + {7:2}cc | + {7:2}dd | + {7:2}ee | + {7:│}ff | + ## grid 3 + :1 | + ## grid 4 + {7:-}^aa | + {7:-}bb | + {7:2}cc | + {7:2}dd | + {7:2}ee | + {7:│}ff | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 1, 23) + screen:expect([[ + {7:-}aa {2:│}{7:-}^aa | + {7:-}bb {2:│}{7:-}bb | + {7:2}cc {2:│}{7:2}cc | + {7:2}dd {2:│}{7:2}dd | + {7:2}ee {2:│}{7:2}ee | + {7:│}ff {2:│}{7:│}ff | + {2:[No Name] [+] }{3:[No Name] [+] }| + :1 | + ]]) + end + + if multigrid then + meths.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:----------------------]| + {3:[No Name] [+] }{2:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + {7:-}aa | + {7:+}{5:^+--- 4 lines: bb····}| + {7:│}ff | + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :1 | + ## grid 4 + {7:-}aa | + {7:-}bb | + {7:2}cc | + {7:2}dd | + {7:2}ee | + {7:│}ff | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 1, 0) + screen:expect([[ + {7:-}aa {2:│}{7:-}aa | + {7:+}{5:^+--- 4 lines: bb····}{2:│}{7:-}bb | + {7:│}ff {2:│}{7:2}cc | + {1:~ }{2:│}{7:2}dd | + {1:~ }{2:│}{7:2}ee | + {1:~ }{2:│}{7:│}ff | + {3:[No Name] [+] }{2:[No Name] [+] }| + :1 | + ]]) + end + + if multigrid then + meths.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:----------------------]| + {3:[No Name] [+] }{2:[No Name] [+] }| + [3:---------------------------------------------]| + ## grid 2 + {7:+}{5:^+-- 6 lines: aa·····}| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + ## grid 3 + :1 | + ## grid 4 + {7:-}aa | + {7:-}bb | + {7:2}cc | + {7:2}dd | + {7:2}ee | + {7:│}ff | + ]]) + else + meths.input_mouse('left', 'press', '', 0, 0, 0) + screen:expect([[ + {7:+}{5:^+-- 6 lines: aa·····}{2:│}{7:-}aa | + {1:~ }{2:│}{7:-}bb | + {1:~ }{2:│}{7:2}cc | + {1:~ }{2:│}{7:2}dd | + {1:~ }{2:│}{7:2}ee | + {1:~ }{2:│}{7:│}ff | + {3:[No Name] [+] }{2:[No Name] [+] }| + :1 | + ]]) + end + end) + it("works with tab", function() insert([[ aa diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua index 9313a35708..ea8968a653 100644 --- a/test/functional/ui/input_spec.lua +++ b/test/functional/ui/input_spec.lua @@ -1,16 +1,18 @@ local helpers = require('test.functional.helpers')(after_each) -local clear, feed_command, nvim = helpers.clear, helpers.feed_command, helpers.nvim +local clear, feed_command = helpers.clear, helpers.feed_command local feed, next_msg, eq = helpers.feed, helpers.next_msg, helpers.eq local command = helpers.command local expect = helpers.expect +local meths = helpers.meths +local exec_lua = helpers.exec_lua local write_file = helpers.write_file local Screen = require('test.functional.ui.screen') -describe('mappings', function() - local cid +before_each(clear) +describe('mappings', function() local add_mapping = function(mapping, send) - local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '" + local cmd = "nnoremap "..mapping.." :call rpcnotify(1, 'mapped', '" ..send:gsub('<', '<lt>').."')<cr>" feed_command(cmd) end @@ -21,8 +23,6 @@ describe('mappings', function() end before_each(function() - clear() - cid = nvim('get_api_info')[1] add_mapping('<C-L>', '<C-L>') add_mapping('<C-S-L>', '<C-S-L>') add_mapping('<s-up>', '<s-up>') @@ -115,7 +115,6 @@ describe('mappings', function() end) describe('input utf sequences that contain CSI/K_SPECIAL', function() - before_each(clear) it('ok', function() feed('i…<esc>') expect('…') @@ -129,7 +128,6 @@ describe('input non-printable chars', function() it("doesn't crash when echoing them back", function() write_file("Xtest-overwrite", [[foobar]]) - clear() local screen = Screen.new(60,8) screen:set_default_attr_ids({ [1] = {bold = true, foreground = Screen.colors.Blue1}, @@ -215,3 +213,27 @@ describe('input non-printable chars', function() ]]) end) end) + +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}) + + exec_lua [[ + winning = false + burst = vim.schedule_wrap(function(tell) + if tell then + vim.rpcnotify(1, 'start') + end + -- Are we winning, son? + if not winning then + burst(false) + end + end) + burst(true) + ]] + + eq({'notification', 'start', {}}, next_msg()) + feed '<f2>' + eq({'notification', 'stop', {}}, next_msg()) + end) +end) |