Fix selecting recent node in CreateDialog
If the node name matches exactly as the search, the node should be selected. This also fixes when the user clicks on recent nodes. Fixes #24044
This commit is contained in:
parent
9762372329
commit
a8a293832e
1 changed files with 30 additions and 23 deletions
|
@ -191,10 +191,16 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
|
|||
item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
|
||||
item->set_selectable(0, false);
|
||||
} else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) {
|
||||
String search_term = search_box->get_text().to_lower();
|
||||
|
||||
// if the node name matches exactly as the search, the node should be selected.
|
||||
// this also fixes when the user clicks on recent nodes.
|
||||
if (p_type.to_lower() == search_term) {
|
||||
*to_select = item;
|
||||
} else {
|
||||
bool current_type_prefered = _is_type_prefered(p_type);
|
||||
bool selected_type_prefered = *to_select ? _is_type_prefered((*to_select)->get_text(0).split(" ")[0]) : false;
|
||||
|
||||
String search_term = search_box->get_text().to_lower();
|
||||
bool is_subsequence_of_type = search_box->get_text().is_subsequence_ofi(p_type);
|
||||
bool is_substring_of_type = p_type.to_lower().find(search_term) >= 0;
|
||||
bool is_substring_of_selected = false;
|
||||
|
@ -223,6 +229,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bool(EditorSettings::get_singleton()->get("docks/scene_tree/start_create_dialog_fully_expanded"))) {
|
||||
item->set_collapsed(false);
|
||||
|
|
Loading…
Reference in a new issue