diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-03-04 10:59:44 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-03-16 19:53:21 +0100 |
commit | be8ebba325451b387c0aedacfcda6c53e6c51188 (patch) | |
tree | 6ee90da21194166b5163fa6375e4f50ab1813626 /test | |
parent | 175398f21645552b708a7626309b826ae0f3d8a8 (diff) | |
download | rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.tar.gz rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.tar.bz2 rneovim-be8ebba325451b387c0aedacfcda6c53e6c51188.zip |
Allow using internal popupmenu or ext_popupmenu for wildmenu
Deprecate ext_wildmenu. ext_popupmenu already contains more state (anchor
position), and will allow further expansion (info about items).
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/ui/cmdline_spec.lua | 131 | ||||
-rw-r--r-- | test/functional/ui/float_spec.lua | 8 | ||||
-rw-r--r-- | test/functional/ui/messages_spec.lua | 6 | ||||
-rw-r--r-- | test/functional/ui/popupmenu_spec.lua | 264 | ||||
-rw-r--r-- | test/functional/ui/screen.lua | 5 |
5 files changed, 387 insertions, 27 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua index 5d112d7f35..16be846647 100644 --- a/test/functional/ui/cmdline_spec.lua +++ b/test/functional/ui/cmdline_spec.lua @@ -600,6 +600,137 @@ local function test_cmdline(linegrid) pos = 12, }}} end) + + it('works together with ext_popupmenu', function() + local expected = { + {'define', '', '', ''}, + {'jump', '', '', ''}, + {'list', '', '', ''}, + {'place', '', '', ''}, + {'undefine', '', '', ''}, + {'unplace', '', '', ''}, + } + + command('set wildmode=full') + command('set wildmenu') + screen:set_option('ext_popupmenu', true) + feed(':sign <tab>') + + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign define"}}, + pos = 11, + }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + + feed('<tab>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign jump"}}, + pos = 9, + }}, popupmenu={items=expected, pos=1, anchor={-1, 0, 5}}} + + feed('<left><left>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign "}}, + pos = 5, + }}, popupmenu={items=expected, pos=-1, anchor={-1, 0, 5}}} + + feed('<right>') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign define"}}, + pos = 11, + }}, popupmenu={items=expected, pos=0, anchor={-1, 0, 5}}} + + feed('a') + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign definea"}}, + pos = 12, + }}} + feed('<esc>') + + -- check positioning with multibyte char in pattern + command("e långfile1") + command("sp långfile2") + feed(':b lå<tab>') + screen:expect{grid=[[ + ^ | + {3:långfile2 }| + | + {2:långfile1 }| + | + ]], popupmenu={ + anchor = { -1, 0, 2 }, + items = {{ "långfile1", "", "", "" }, { "långfile2", "", "", "" }}, + pos = 0 + }, cmdline={{ + content = {{ "b långfile1" }}, + firstc = ":", + pos = 12 + }}} + end) + + it('ext_wildmenu takes precedence over ext_popupmenu', function() + local expected = { + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', + } + + command('set wildmode=full') + command('set wildmenu') + screen:set_option('ext_wildmenu', true) + screen:set_option('ext_popupmenu', true) + feed(':sign <tab>') + + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + | + ]], cmdline={{ + firstc = ":", + content = {{"sign define"}}, + pos = 11, + }}, wildmenu_items=expected, wildmenu_pos=0} + end) + end -- the representation of cmdline and cmdline_block contents changed with ext_linegrid diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua index bb3255840e..375e98379a 100644 --- a/test/functional/ui/float_spec.lua +++ b/test/functional/ui/float_spec.lua @@ -1341,7 +1341,7 @@ describe('floating windows', function() ]], float_pos={ [3] = {{ id = 1001 }, "NW", 1, 2, 5, true}, }, popupmenu={ - anchor = {0, 2, 3}, items = items, pos = 0 + anchor = {3, 0, 2}, items = items, pos = 0 }} else screen:expect{grid=[[ @@ -1353,7 +1353,7 @@ describe('floating windows', function() {0:~ }{12:~ }{0: }| {3:-- INSERT --} | ]], popupmenu={ - anchor = {2, 7}, items = items, pos = 0 + anchor = {1, 2, 7}, items = items, pos = 0 }} end @@ -1423,7 +1423,7 @@ describe('floating windows', function() ]], float_pos={ [3] = {{ id = 1001 }, "NW", 1, 2, 5, true}, }, popupmenu={ - anchor = {0, 0, 2}, items = items, pos = 0 + anchor = {2, 0, 0}, items = items, pos = 0 }} else screen:expect{grid=[[ @@ -1435,7 +1435,7 @@ describe('floating windows', function() {0:~ }{12:~ }{0: }| {3:-- INSERT --} | ]], popupmenu={ - anchor = {0, 0}, items = items, pos = 0 + anchor = {1, 0, 0}, items = items, pos = 0 }} end diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua index 388c6b3e95..efa776762b 100644 --- a/test/functional/ui/messages_spec.lua +++ b/test/functional/ui/messages_spec.lua @@ -179,7 +179,7 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| ]], popupmenu={ - anchor = { 2, 0 }, + anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, pos = 1 }, showmode={ { "-- Keyword Local completion (^N^P) ", 3 }, { "match 1 of 2", 4 } }} @@ -194,7 +194,7 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| ]], popupmenu={ - anchor = { 2, 0 }, + anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, pos = 1 }, messages={ { @@ -210,7 +210,7 @@ describe('ui/ext_messages', function() {1:~ }| {1:~ }| ]], popupmenu={ - anchor = { 2, 0 }, + anchor = { 1, 2, 0 }, items = { { "alphpabet", "", "", "" }, { "alphanum", "", "", "" } }, pos = 0 }, messages={ { diff --git a/test/functional/ui/popupmenu_spec.lua b/test/functional/ui/popupmenu_spec.lua index 1e6ebb87f5..b457ebebab 100644 --- a/test/functional/ui/popupmenu_spec.lua +++ b/test/functional/ui/popupmenu_spec.lua @@ -50,7 +50,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=0, - anchor={1,0}, + anchor={1,1,0}, }} feed('<c-p>') @@ -66,7 +66,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=-1, - anchor={1,0}, + anchor={1,1,0}, }} -- down moves the selection in the menu, but does not insert anything @@ -83,7 +83,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=1, - anchor={1,0}, + anchor={1,1,0}, }} feed('<cr>') @@ -113,7 +113,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=0, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(1,false,false,{}) @@ -129,7 +129,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=1, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(2,true,false,{}) @@ -145,7 +145,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=2, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(0,true,true,{}) @@ -174,7 +174,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=0, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(-1,false,false,{}) @@ -190,7 +190,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=-1, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(1,true,false,{}) @@ -206,7 +206,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=1, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(-1,true,false,{}) @@ -222,7 +222,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=-1, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(0,true,false,{}) @@ -238,7 +238,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=0, - anchor={1,0}, + anchor={1,1,0}, }} meths.select_popupmenu_item(-1,true,true,{}) @@ -269,7 +269,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=0, - anchor={1,0}, + anchor={1,1,0}, }} feed('<f1>') @@ -285,7 +285,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=2, - anchor={1,0}, + anchor={1,1,0}, }} feed('<f2>') @@ -301,7 +301,7 @@ describe('ui/ext_popupmenu', function() ]], popupmenu={ items=expected, pos=-1, - anchor={1,0}, + anchor={1,1,0}, }} feed('<f3>') @@ -366,6 +366,113 @@ describe('ui/ext_popupmenu', function() {2:-- INSERT --} | ]]) end) + + it('works with wildoptions=pum', function() + screen:try_resize(32,10) + command('set wildmenu') + command('set wildoptions=pum') + + local wild_expected = { + {'define', '', '', ''}, + {'jump', '', '', ''}, + {'list', '', '', ''}, + {'place', '', '', ''}, + {'undefine', '', '', ''}, + {'unplace', '', '', ''}, + } + + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]]) + + feed('<tab>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign define^ | + ]], popupmenu={items=wild_expected, pos=0, anchor={1, 9, 6}}} + + feed('<left>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]], popupmenu={items=wild_expected, pos=-1, anchor={1, 9, 6}}} + + feed('<left>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplace^ | + ]], popupmenu={items=wild_expected, pos=5, anchor={1, 9, 6}}} + + feed('x') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplacex^ | + ]]) + feed('<esc>') + + -- check positioning with multibyte char in pattern + command("e långfile1") + command("sp långfile2") + feed(':b lå<tab>') + screen:expect{grid=[[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }| + {3:långfile1 }| + :b långfile1^ | + ]], popupmenu={ + anchor = {1, 9, 3}, + items = {{"långfile1", "", "", "" }, {"långfile2", "", "", ""}}, + pos = 0, + }} + end) end) @@ -1209,7 +1316,7 @@ describe('builtin popupmenu', function() ]]) meths.input_mouse('wheel', 'down', '', 0, 6, 15) - screen:expect([[ + screen:expect{grid=[[ choice^ | {1:~ }| {n:word }{1: }| @@ -1218,7 +1325,7 @@ describe('builtin popupmenu', function() {n:thing }{1: }| {3:[No Name] [+] }| {2:-- INSERT --} | - ]]) + ]], unchanged=true} end) it('works with kind, menu and abbr attributes', function() @@ -1273,6 +1380,131 @@ describe('builtin popupmenu', function() ]]) end) + it('works with wildoptions=pum', function() + screen:try_resize(32,10) + command('set wildmenu') + command('set wildoptions=pum') + + feed(':sign ') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign ^ | + ]]) + + feed('<tab>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{s: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign define^ | + ]]) + + feed('<left>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{n: unplace }{1: }| + :sign ^ | + ]]) + + feed('<left>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }{n: define }{1: }| + {1:~ }{n: jump }{1: }| + {1:~ }{n: list }{1: }| + {1:~ }{n: place }{1: }| + {1:~ }{n: undefine }{1: }| + {1:~ }{s: unplace }{1: }| + :sign unplace^ | + ]]) + + feed('x') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + :sign unplacex^ | + ]]) + + feed('<esc>') + + -- check positioning with multibyte char in pattern + command("e långfile1") + command("sp långfile2") + feed(':b lå<tab>') + screen:expect([[ + | + {1:~ }| + {1:~ }| + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }{s: långfile1 }{1: }| + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + + -- check doesn't crash on screen resize + screen:try_resize(20,6) + screen:expect([[ + | + {1:~ }| + {4:långfile2 }| + {s: långfile1 } | + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + + screen:try_resize(50,15) + screen:expect([[ + | + {1:~ }| + {4:långfile2 }| + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }{s: långfile1 }{1: }| + {3:lå}{n: långfile2 }{3: }| + :b långfile1^ | + ]]) + end) + it("'pumblend' RGB-color", function() screen:try_resize(60,14) screen:set_default_attr_ids({ diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua index 8b1b77eb81..d072444ee1 100644 --- a/test/functional/ui/screen.lua +++ b/test/functional/ui/screen.lua @@ -937,10 +937,7 @@ function Screen:_handle_option_set(name, value) end function Screen:_handle_popupmenu_show(items, selected, row, col, grid) - if (not self._options.ext_multigrid) and grid == 1 then - grid = nil - end - self.popupmenu = {items=items, pos=selected, anchor={row, col, grid}} + self.popupmenu = {items=items, pos=selected, anchor={grid, row, col}} end function Screen:_handle_popupmenu_select(selected) |