characters: Display correct content for built-in menus

When the `ShowBuiltinCharacters` setting is active, the index of the
built-in menus was off by one.

That's because if we find a match, we exit the loop without
incrementing the `menu` variable, so we find a match for the builtin
that follows as well.

A similar problem exists for constants.

Fixes: #1054

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2024-07-27 13:37:34 +02:00
parent 384684cb83
commit 1ca1be761f
2 changed files with 5 additions and 1 deletions

View file

@ -300,6 +300,7 @@ MENU_BODY(character_menu)
utf8 end = val + len;
for (utf8 p = val; p < end; p = utf8_next(p))
matching++;
menu = id(menu + 1);
break;
}
menu = id(menu + 1);

View file

@ -703,6 +703,7 @@ bool constant_menu::do_submenu(constant::config_r cfg, menu_info &mi) const
position = cfile.position();
while (cfile.next(false))
matching++;
menu = id(menu + 1);
break;
}
menu = id(menu + 1);
@ -717,6 +718,7 @@ bool constant_menu::do_submenu(constant::config_r cfg, menu_info &mi) const
bool found = false;
auto builtins = cfg.builtins;
size_t maxb = cfg.nbuiltins;
for (size_t b = 0; b < maxb; b += 2)
{
if (!builtins[b + 1] || !*builtins[b + 1])
@ -736,7 +738,8 @@ bool constant_menu::do_submenu(constant::config_r cfg, menu_info &mi) const
break;
}
}
count = (last - first) / 2;
if (found)
count = (last - first) / 2;
}
items_init(mi, count + matching, 2, 1);