Browse Source

Fix 'Show in FileSystem' jumps to incorrect entry under certain conditions

Marius Hanl 7 months ago
parent
commit
f0ae69ed8e
1 changed files with 2 additions and 1 deletions
  1. 2 1
      editor/filesystem_dock.cpp

+ 2 - 1
editor/filesystem_dock.cpp

@@ -746,7 +746,8 @@ void FileSystemDock::_navigate_to_path(const String &p_path, bool p_select_in_fa
 	// Select the file or directory in the tree.
 	// Select the file or directory in the tree.
 	tree->deselect_all();
 	tree->deselect_all();
 	if (display_mode == DISPLAY_MODE_TREE_ONLY) {
 	if (display_mode == DISPLAY_MODE_TREE_ONLY) {
-		const String file_name = is_directory ? target_path.trim_suffix("/").get_file() + "/" : target_path.get_file();
+		// Either search for 'folder/' or '/file.ext'.
+		const String file_name = is_directory ? target_path.trim_suffix("/").get_file() + "/" : "/" + target_path.get_file();
 		TreeItem *item = is_directory ? *directory_ptr : (*directory_ptr)->get_first_child();
 		TreeItem *item = is_directory ? *directory_ptr : (*directory_ptr)->get_first_child();
 		while (item) {
 		while (item) {
 			if (item->get_metadata(0).operator String().ends_with(file_name)) {
 			if (item->get_metadata(0).operator String().ends_with(file_name)) {