Repository: godotengine/godot
File: editor/docks/filesystem_dock.cpp (C++)

Code before:
		for (int i = 0; i < dock_filesystem_selected_paths.size(); i++) {
			select_file(dock_filesystem_selected_paths[i]);
		}
	}

	// Restore collapsed state.
	PackedStringArray uncollapsed_tis;
	if (p_layout->has_section_key(p_section, "uncollapsed_paths")) {
		uncollapsed_tis = p_layout->get_value(p_section, "uncollapsed_paths");
	} else {
		uncollapsed_tis = { "res://" };
	}

	if (!uncollapsed_tis.is_empty()) {
		for (int i = 0; i < uncollapsed_tis.size(); i++) {
			TreeItem *uncollapsed_ti = get_tree_control()->get_item_with_metadata(uncollapsed_tis[i], 0);
			if (uncollapsed_ti) {
				uncollapsed_ti->set_collapsed(false);
			}
		}
		get_tree_control()->queue_redraw();
	}
}

void FileSystemDock::_on_unrecognized_ext_dialog_button_pressed(const StringName &p_action) {
	if (p_action == StringName("open_editor_settings_docks_filesystem")) {
		unrecognized_ext_dialog->hide();
		EditorSettingsDialog *ed_settings = EditorNode::get_singleton()->editor_settings_dialog;
		ed_settings->popup_edit_settings();
		ed_settings->set_current_section("docks/filesystem");
	}
}

void FileSystemDock::_bind_methods() {
	ClassDB::bind_method(D_METHOD("navigate_to_path", "path"), &FileSystemDock::navigate_to_path);

	ClassDB::bind_method(D_METHOD("add_resource_tooltip_plugin", "plugin"), &FileSystemDock::add_resource_tooltip_plugin);
	ClassDB::bind_method(D_METHOD("remove_resource_tooltip_plugin", "plugin"), &FileSystemDock::remove_resource_tooltip_plugin);

	ADD_SIGNAL(MethodInfo("inherit", PropertyInfo(Variant::STRING, "file")));
	ADD_SIGNAL(MethodInfo("instantiate", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files")));

	ADD_SIGNAL(MethodInfo("resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, Resource::get_class_static())));
	ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file")));
	ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder")));
	ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
	ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_folder")));
	ADD_SIGNAL(MethodInfo("folder_color_changed"));
	ADD_SIGNAL(MethodInfo("selection_changed"));

	ADD_SIGNAL(MethodInfo("display_mode_changed"));

Review comment (suggestion):
```suggestion
	if (p_action == SNAME("open_editor_settings_docks_filesystem")) {
```
Or just
```suggestion
	if (p_action == "open_editor_settings_docks_filesystem") {
```
`SNAME` creates a local static variable with the name, but using `StringName` adds unnecessary lookup

Code after:
		for (int i = 0; i < dock_filesystem_selected_paths.size(); i++) {
			select_file(dock_filesystem_selected_paths[i]);
		}
	}

	// Restore collapsed state.
	PackedStringArray uncollapsed_tis;
	if (p_layout->has_section_key(p_section, "uncollapsed_paths")) {
		uncollapsed_tis = p_layout->get_value(p_section, "uncollapsed_paths");
	} else {
		uncollapsed_tis = { "res://" };
	}

	if (!uncollapsed_tis.is_empty()) {
		for (int i = 0; i < uncollapsed_tis.size(); i++) {
			TreeItem *uncollapsed_ti = get_tree_control()->get_item_with_metadata(uncollapsed_tis[i], 0);
			if (uncollapsed_ti) {
				uncollapsed_ti->set_collapsed(false);
			}
		}
		get_tree_control()->queue_redraw();
	}
}

void FileSystemDock::_on_open_editor_settings_file_exts() {
	unrecognized_ext_dialog->hide();

	// The FileSystem settings are under "advanced settings", so we have to ensure
	// that setting is enabled before we attempt to open the menu to them.
	EditorSettingsDialog *ed_settings = EditorNode::get_singleton()->editor_settings_dialog;
	ed_settings->set_advanced_mode_enabled(true);
	ed_settings->popup_edit_settings();
	ed_settings->set_current_section("docks/filesystem");
}

void FileSystemDock::_bind_methods() {
	ClassDB::bind_method(D_METHOD("navigate_to_path", "path"), &FileSystemDock::navigate_to_path);

	ClassDB::bind_method(D_METHOD("add_resource_tooltip_plugin", "plugin"), &FileSystemDock::add_resource_tooltip_plugin);
	ClassDB::bind_method(D_METHOD("remove_resource_tooltip_plugin", "plugin"), &FileSystemDock::remove_resource_tooltip_plugin);

	ADD_SIGNAL(MethodInfo("inherit", PropertyInfo(Variant::STRING, "file")));
	ADD_SIGNAL(MethodInfo("instantiate", PropertyInfo(Variant::PACKED_STRING_ARRAY, "files")));

	ADD_SIGNAL(MethodInfo("resource_removed", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, Resource::get_class_static())));
	ADD_SIGNAL(MethodInfo("file_removed", PropertyInfo(Variant::STRING, "file")));
	ADD_SIGNAL(MethodInfo("folder_removed", PropertyInfo(Variant::STRING, "folder")));
	ADD_SIGNAL(MethodInfo("files_moved", PropertyInfo(Variant::STRING, "old_file"), PropertyInfo(Variant::STRING, "new_file")));
	ADD_SIGNAL(MethodInfo("folder_moved", PropertyInfo(Variant::STRING, "old_folder"), PropertyInfo(Variant::STRING, "new_folder")));
	ADD_SIGNAL(MethodInfo("folder_color_changed"));
	ADD_SIGNAL(MethodInfo("selection_changed"));