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

Code before:

	if (new_scene) {
		if (new_scene->get_parent() != scene_root) {
			scene_root->add_child(new_scene, true);
		}
	}

	if (editor_data.check_and_update_scene(p_idx)) {
		if (!editor_data.get_scene_path(p_idx).is_empty()) {
			editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx));
		}

		EditorUndoRedoManager::get_singleton()->clear_history(editor_data.get_scene_history_id(p_idx), false);
	}

	Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history);
	_edit_current(true);

	_update_title();
	callable_mp(scene_tabs, &EditorSceneTabs::update_scene_tabs).call_deferred();

	if (tabs_to_close.is_empty()) {
		callable_mp(this, &EditorNode::_set_main_scene_state).call_deferred(state, get_edited_scene()); // Do after everything else is done setting up.
	}

	if (EDITOR_GET("interface/scene_tabs/auto_select_current_scene_file")) {
		callable_mp(this, &EditorNode::_nav_to_selected_scene).call_deferred(p_idx);
	}

	_update_undo_redo_allowed();
	_update_unsaved_cache();
}

void EditorNode::_nav_to_selected_scene(int p_idx) const {
	FileSystemDock::get_singleton()->navigate_to_path(editor_data.get_scene_path(p_idx));
}

void EditorNode::setup_color_picker(ColorPicker *p_picker) {
	p_picker->set_editor_settings(EditorSettings::get_singleton());
	int default_color_mode = EditorSettings::get_singleton()->get_project_metadata("color_picker", "color_mode", EDITOR_GET("interface/inspector/default_color_picker_mode"));
	int picker_shape = EditorSettings::get_singleton()->get_project_metadata("color_picker", "picker_shape", EDITOR_GET("interface/inspector/default_color_picker_shape"));
	bool show_intensity = EditorSettings::get_singleton()->get_project_metadata("color_picker", "show_intensity", EDITOR_GET("interface/inspector/color_picker_show_intensity"));

	p_picker->set_color_mode((ColorPicker::ColorModeType)default_color_mode);
	p_picker->set_picker_shape((ColorPicker::PickerShapeType)picker_shape);
	p_picker->set_edit_intensity(show_intensity);

	p_picker->set_quick_open_callback(callable_mp(this, &EditorNode::_palette_quick_open_dialog));
	p_picker->set_palette_saved_callback(callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::update_file));
	palette_file_selected_callback = callable_mp(p_picker, &ColorPicker::_quick_open_palette_file_selected);
}

Review comment (suggestion):
You should also add check for `restoring_scenes`, otherwise this is called for every restored scene at launch.

Code after:
	}

	if (Popup *p = Object::cast_to<Popup>(new_scene)) {
		p->show();
	}

	SceneTreeDock::get_singleton()->set_edited_scene(new_scene);
	if (get_tree()) {
		get_tree()->set_edited_scene_root(new_scene);
	}

	if (new_scene) {
		if (new_scene->get_parent() != scene_root) {
			scene_root->add_child(new_scene, true);
		}
	}

	if (editor_data.check_and_update_scene(p_idx)) {
		if (!editor_data.get_scene_path(p_idx).is_empty()) {
			editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx));
		}

		EditorUndoRedoManager::get_singleton()->clear_history(editor_data.get_scene_history_id(p_idx), false);
	}

	Dictionary state = editor_data.restore_edited_scene_state(editor_selection, &editor_history);
	_edit_current(true);

	_update_title();
	callable_mp(scene_tabs, &EditorSceneTabs::update_scene_tabs).call_deferred();

	if (tabs_to_close.is_empty()) {
		callable_mp(this, &EditorNode::_set_main_scene_state).call_deferred(state, get_edited_scene()); // Do after everything else is done setting up.
	}

	if (!select_current_scene_file_requested && EDITOR_GET("interface/scene_tabs/auto_select_current_scene_file")) {
		select_current_scene_file_requested = true;
		callable_mp(this, &EditorNode::_nav_to_selected_scene).call_deferred();
	}

	_update_undo_redo_allowed();
	_update_unsaved_cache();
}

void EditorNode::_nav_to_selected_scene() {
	select_current_scene_file_requested = false;
	const String scene_path = editor_data.get_scene_path(scene_tabs->get_current_tab());
	if (!scene_path.is_empty()) {
		FileSystemDock::get_singleton()->navigate_to_path(scene_path);
	}
}