Browse Source

Merge pull request #25338 from DualMatrix/search_inaccurate

Fixed Recent/Favorite in Create Node dialog not selecting right node
Rémi Verschelde 6 years ago
parent
commit
1365bed8ed
1 changed files with 3 additions and 3 deletions
  1. 3 3
      editor/create_dialog.cpp

+ 3 - 3
editor/create_dialog.cpp

@@ -208,7 +208,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
 	if (!can_instance) {
 	if (!can_instance) {
 		item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
 		item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
 		item->set_selectable(0, false);
 		item->set_selectable(0, false);
-	} else {
+	} else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) {
 		bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type);
 		bool is_search_subsequence = search_box->get_text().is_subsequence_ofi(p_type);
 		String to_select_type = *to_select ? (*to_select)->get_text(0) : "";
 		String to_select_type = *to_select ? (*to_select)->get_text(0) : "";
 		to_select_type = to_select_type.split(" ")[0];
 		to_select_type = to_select_type.split(" ")[0];
@@ -221,11 +221,11 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
 		} else {
 		} else {
 			current_item_is_preferred = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type;
 			current_item_is_preferred = ed.script_class_is_parent(p_type, preferred_search_result_type) && !ed.script_class_is_parent(to_select_type, preferred_search_result_type) && search_box->get_text() != to_select_type;
 		}
 		}
-		if (*to_select && p_type.length() < (*to_select)->get_text(0).length()) {
+		if (search_box->get_text() == p_type || (*to_select && p_type.length() < (*to_select)->get_text(0).length())) {
 			current_item_is_preferred = true;
 			current_item_is_preferred = true;
 		}
 		}
 
 
-		if (((!*to_select || current_item_is_preferred) && is_search_subsequence) || search_box->get_text() == p_type) {
+		if (((!*to_select || current_item_is_preferred) && is_search_subsequence)) {
 			*to_select = item;
 			*to_select = item;
 		}
 		}
 	}
 	}