diff options
Diffstat (limited to 'test/functional/ui/popupmenu_spec.lua')
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 3174 |
1 files changed, 1343 insertions, 1831 deletions
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 |