mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
menu_get(): Do not include empty items
Caused by a typo: `dict` instead of `dic`. Renamed variable to `d` to make it less similar.
This commit is contained in:
parent
827ed144fb
commit
d760e08fac
@ -660,7 +660,8 @@ static void free_menu_string(vimmenu_T *menu, int idx)
|
|||||||
///
|
///
|
||||||
/// @param[in] menu if null, starts from root_menu
|
/// @param[in] menu if null, starts from root_menu
|
||||||
/// @param modes, a choice of \ref MENU_MODES
|
/// @param modes, a choice of \ref MENU_MODES
|
||||||
/// @return a dict with name/commands
|
/// @return dict with name/commands
|
||||||
|
/// @see show_menus_recursive
|
||||||
/// @see menu_get
|
/// @see menu_get
|
||||||
static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
|
static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
|
||||||
{
|
{
|
||||||
@ -715,10 +716,10 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes)
|
|||||||
// visit recursively all children
|
// visit recursively all children
|
||||||
list_T *const children_list = tv_list_alloc(kListLenMayKnow);
|
list_T *const children_list = tv_list_alloc(kListLenMayKnow);
|
||||||
for (menu = menu->children; menu != NULL; menu = menu->next) {
|
for (menu = menu->children; menu != NULL; menu = menu->next) {
|
||||||
dict_T *dic = menu_get_recursive(menu, modes);
|
dict_T *d = menu_get_recursive(menu, modes);
|
||||||
if (tv_dict_len(dict) > 0) {
|
if (tv_dict_len(d) > 0) {
|
||||||
tv_list_append_dict(children_list, dic);
|
tv_list_append_dict(children_list, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tv_dict_add_list(dict, S_LEN("submenus"), children_list);
|
tv_dict_add_list(dict, S_LEN("submenus"), children_list);
|
||||||
}
|
}
|
||||||
|
@ -63,19 +63,21 @@ describe('menu_get', function()
|
|||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
command('nnoremenu &Test.Test inormal<ESC>')
|
command([=[
|
||||||
command('inoremenu Test.Test insert')
|
nnoremenu &Test.Test inormal<ESC>
|
||||||
command('vnoremenu Test.Test x')
|
inoremenu Test.Test insert
|
||||||
command('cnoremenu Test.Test cmdmode')
|
vnoremenu Test.Test x
|
||||||
command('menu Test.Nested.test level1')
|
cnoremenu Test.Test cmdmode
|
||||||
command('menu Test.Nested.Nested2 level2')
|
menu Test.Nested.test level1
|
||||||
|
menu Test.Nested.Nested2 level2
|
||||||
|
|
||||||
command('nnoremenu <script> Export.Script p')
|
nnoremenu <script> Export.Script p
|
||||||
command('tmenu Export.Script This is the tooltip')
|
tmenu Export.Script This is the tooltip
|
||||||
command('menu ]Export.hidden thisoneshouldbehidden')
|
menu ]Export.hidden thisoneshouldbehidden
|
||||||
|
|
||||||
command('nnoremenu Edit.Paste p')
|
nnoremenu Edit.Paste p
|
||||||
command('cnoremenu Edit.Paste <C-R>"')
|
cnoremenu Edit.Paste <C-R>"
|
||||||
|
]=])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("path='', modes='a'", function()
|
it("path='', modes='a'", function()
|
||||||
@ -306,7 +308,7 @@ describe('menu_get', function()
|
|||||||
eq(expected, m)
|
eq(expected, m)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('matching path, default modes', function()
|
it('matching path, all modes', function()
|
||||||
local m = funcs.menu_get("Export", "a")
|
local m = funcs.menu_get("Export", "a")
|
||||||
local expected = {
|
local expected = {
|
||||||
{
|
{
|
||||||
@ -349,8 +351,6 @@ describe('menu_get', function()
|
|||||||
name = "Test",
|
name = "Test",
|
||||||
hidden = 0
|
hidden = 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
priority = 500,
|
priority = 500,
|
||||||
name = "Test"
|
name = "Test"
|
||||||
@ -379,8 +379,6 @@ describe('menu_get', function()
|
|||||||
name = "Test",
|
name = "Test",
|
||||||
hidden = 0
|
hidden = 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
priority = 500,
|
priority = 500,
|
||||||
name = "Test",
|
name = "Test",
|
||||||
|
Loading…
Reference in New Issue
Block a user