From 39e83fa7cb4486d30f788c3b27594d106d5e76ab Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 24 Feb 2017 06:12:34 +0000 Subject: ui: allow external ui to draw wildmenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Björn Linse Updated docs and tests. --- test/functional/ui/wildmode_spec.lua | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) (limited to 'test/functional/ui/wildmode_spec.lua') diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 41a751c284..6ce76568db 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -179,3 +179,102 @@ describe('command line completion', function() ]]) end) end) + +describe('External wildmenu', function() + local screen + local items, selected = nil, nil + + before_each(function() + clear() + screen = Screen.new(25, 5) + screen:attach({rgb=true, ext_wildmenu=true}) + screen:set_on_event_handler(function(name, data) + if name == "wildmenu_show" then + items = data[1] + elseif name == "wildmenu_select" then + selected = data[1] + elseif name == "wildmenu_hide" then + items, selected = nil, nil + end + end) + end) + + after_each(function() + screen:detach() + end) + + it('works with :sign ', function() + local expected = { + 'define', + 'jump', + 'list', + 'place', + 'undefine', + 'unplace', + } + + command('set wildmode=full') + command('set wildmenu') + feed(':sign ') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign jump^ | + ]], nil, nil, function() + eq(expected, items) + eq(1, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign ^ | + ]], nil, nil, function() + eq(expected, items) + eq(-1, selected) + end) + + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign define^ | + ]], nil, nil, function() + eq(expected, items) + eq(0, selected) + end) + + + + feed('a') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign definea^ | + ]], nil, nil, function() + eq(nil, items) + eq(nil, selected) + end) + end) +end) -- cgit