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

Code before:
		bool is_texture = ClassDB::is_parent_class(ResourceLoader::get_resource_type(files[i]), "Texture2D");

		if (is_scene || is_texture) {
			Ref<Resource> res = ResourceLoader::load(files[i]);
			if (res.is_null()) {
				continue;
			}
			Ref<PackedScene> scn = res;
			if (scn.is_valid()) {
				Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
				if (!instantiated_scene) {
					continue;
				}
				memdelete(instantiated_scene);
			}
			can_instantiate = true;
			break;
		}
	}
	if (can_instantiate) {
		if (!preview_node->get_parent()) { // create preview only once
			_create_preview(files);
		}
		ERR_FAIL_COND_V(preview_node->get_child_count() == 0, false);

		Transform2D trans = canvas_item_editor->get_canvas_transform();
		preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
		String scene_file_path = preview_node->get_child(0)->get_scene_file_path();
		if (scene_file_path.is_empty() || preview_node->get_tree()->get_edited_scene_root()) {
			double snap = EDITOR_GET("interface/inspector/default_float_step");
			int snap_step_decimals = Math::range_step_decimals(snap);
#define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals)))
			Vector2 preview_node_pos = preview_node->get_global_position();
			canvas_item_editor->message = TTR("Instantiating:") + " (" + FORMAT(preview_node_pos.x) + ", " + FORMAT(preview_node_pos.y) + ") px";
			label->set_text(vformat(TTR("Adding %s..."), default_texture_node_type));
		} else {
			canvas_item_editor->message = TTR("Creating inherited scene from: ") + scene_file_path;
		}

		canvas_item_editor->update_viewport();
	}
	return can_instantiate;
}

void CanvasItemEditorViewport::_show_resource_type_selector() {
	_remove_preview();
	List<BaseButton *> btn_list;
	button_group->get_buttons(&btn_list);

	for (int i = 0; i < btn_list.size(); i++) {
		CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]);

Review comment (suggestion):
```suggestion
		canvas_item_editor->message = vformat(TTR("Can't instantiate: %s."), TTR("Cyclical dependency found"));
```
This message is a nice touch. Maybe we could have one for other problems too.

Code after:
		bool is_texture = ClassDB::is_parent_class(ResourceLoader::get_resource_type(files[i]), "Texture2D");

		if (is_scene || is_texture) {
			Ref<Resource> res = ResourceLoader::load(files[i]);
			if (res.is_null()) {
				continue;
			}
			Ref<PackedScene> scn = res;
			if (scn.is_valid()) {
				Node *instantiated_scene = scn->instantiate(PackedScene::GEN_EDIT_STATE_INSTANCE);
				if (!instantiated_scene) {
					continue;
				}

				Node *edited_scene = EditorNode::get_singleton()->get_edited_scene();
				if (_cyclical_dependency_exists(edited_scene->get_scene_file_path(), instantiated_scene)) {
					memdelete(instantiated_scene);
					can_instantiate = false;
					is_cyclical_dep = true;
					error_file = files[i].get_file();
					break;
				}
				memdelete(instantiated_scene);
			}
			can_instantiate = true;
		}
	}
	if (is_cyclical_dep) {
		canvas_item_editor->message = vformat(TTR("Can't instantiate: %s."), vformat(TTR("Circular dependency found at %s"), error_file));
		canvas_item_editor->update_viewport();
		return false;
	}
	if (can_instantiate) {
		if (!preview_node->get_parent()) { // create preview only once
			_create_preview(files);
		}
		ERR_FAIL_COND_V(preview_node->get_child_count() == 0, false);

		Transform2D trans = canvas_item_editor->get_canvas_transform();
		preview_node->set_position((p_point - trans.get_origin()) / trans.get_scale().x);
		String scene_file_path = preview_node->get_child(0)->get_scene_file_path();
		if (scene_file_path.is_empty() || preview_node->get_tree()->get_edited_scene_root()) {
			double snap = EDITOR_GET("interface/inspector/default_float_step");
			int snap_step_decimals = Math::range_step_decimals(snap);
#define FORMAT(value) (TS->format_number(String::num(value, snap_step_decimals)))
			Vector2 preview_node_pos = preview_node->get_global_position();
			canvas_item_editor->message = TTR("Instantiating:") + " (" + FORMAT(preview_node_pos.x) + ", " + FORMAT(preview_node_pos.y) + ") px";
			label->set_text(vformat(TTR("Adding %s..."), default_texture_node_type));
		} else {
			canvas_item_editor->message = TTR("Creating inherited scene from: ") + scene_file_path;
		}