look_menu_search: fix crash due to certain cursor keys not restoring list

Fixes #1737
develop
lethosor 2020-12-30 15:04:43 -05:00
parent a7232499ac
commit b585bca90b
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
1 changed files with 10 additions and 7 deletions

@ -115,13 +115,16 @@ static string get_unit_description(df::unit *unit)
return desc;
}
static bool cursor_key_pressed (std::set<df::interface_key> *input)
static bool cursor_key_pressed (std::set<df::interface_key> *input, bool in_entry_mode)
{
// give text input (e.g. "2") priority over cursor keys
for (auto it = input->begin(); it != input->end(); ++it)
if (in_entry_mode)
{
if (Screen::keyToChar(*it) != -1)
return false;
// give text input (e.g. "2") priority over cursor keys
for (auto it = input->begin(); it != input->end(); ++it)
{
if (Screen::keyToChar(*it) != -1)
return false;
}
}
return
input->count(df::interface_key::CURSOR_UP) ||
@ -249,7 +252,7 @@ public:
// ENTER or ESC: leave typing mode
end_entry_mode();
}
else if (cursor_key_pressed(input))
else if (cursor_key_pressed(input, entry_mode))
{
// Arrow key pressed. Leave entry mode and allow screen to process key
end_entry_mode();
@ -1953,7 +1956,7 @@ public:
end_entry_mode();
return false;
}
if (cursor_key_pressed(input))
if (cursor_key_pressed(input, in_entry_mode()))
{
end_entry_mode();
clear_search();