Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exact match search in debug spawns and fix duplicated debug key #1936

Merged
merged 5 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ void character_edit_menu( Character &c )

std::vector<uilist_entry> menu_entries = static_entries;
if( !spell_type::get_all().empty() ) {
menu_entries.emplace_back( edit_character::learn_spells, true, 'S', _( "Learn all [S]pells" ) );
menu_entries.emplace_back( edit_character::level_spells, true, 'L', _( "[L]evel a spell" ) );
menu_entries.emplace_back( edit_character::learn_spells, true, 'L', _( "[L]earn all Spells" ) );
menu_entries.emplace_back( edit_character::level_spells, true, 'v', _( "Le[v]el a spell" ) );
}
if( p.is_npc() ) {
menu_entries.emplace_back( edit_character::mission_add, true, 'm', _( "Add [m]ission" ) );
Expand Down
12 changes: 11 additions & 1 deletion src/ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,19 @@ void uilist::filterlist()

int f = 0;
int num_entries = entries.size();
// check if string begin by " and finish by ". If that's the case, we only return a result if it matches it exactly
bool exact_match_only = !filter.empty() && filter.front() == '\"' && filter.back() == '\"';
if( exact_match_only ) {
filter.erase( std::remove( filter.begin(), filter.end(), '\"' ), filter.end() );
}

for( int i = 0; i < num_entries; i++ ) {
if( filtering ) {
if( ignore_case ) {
if( exact_match_only ) {
if( !( entries[i].txt == filter ) ) {
continue;
}
} else if( ignore_case ) {
if( !lcmatch( entries[i].txt, filter ) ) {
continue;
}
Expand Down