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

Code before:
	// A double-click should always be taken as a "confirm" action.
	if (p_double_click) {
		container->save_selected_item();
		ok_pressed();
		return;
	}

	// Single-clicks should be taken as a "confirm" action only if Instant Preview
	// isn't currently enabled, or the property object is null for some reason.
	if (!_is_instant_preview_active()) {
		container->save_selected_item();
		ok_pressed();
	}
}

void EditorQuickOpenDialog::preview_property() {
	Ref<Resource> loaded_resource = ResourceLoader::load(container->get_selected());
	ERR_FAIL_COND_MSG(loaded_resource.is_null(), "Cannot load resource from path '" + container->get_selected() + "'.");

	// MultiNodeEdit has adding to the undo/redo stack baked into its set function.
	// As such, we have to specifically call a version of its setter that doesn't
	// create undo/redo actions.
	property_object->set_block_signals(true);
	if (Object::cast_to<MultiNodeEdit>(property_object)) {
		Object::cast_to<MultiNodeEdit>(property_object)->_set_impl(property_path, loaded_resource, "", false);
	} else {
		property_object->set(property_path, loaded_resource);
	}
	property_object->set_block_signals(false);
}

void EditorQuickOpenDialog::update_property() {
	// Set the property back to the initial value first, so that the undo action
	// has the correct object.
	if (property_object) {
		if (Object::cast_to<MultiNodeEdit>(property_object)) {
			Object::cast_to<MultiNodeEdit>(property_object)->_set_impl(property_path, initial_property_value, "", false);
		} else {
			property_object->set(property_path, initial_property_value);
		}
	}

	if (!item_selected_callback.is_valid()) {
		String err_msg = "The callback provided to the Quick Open dialog was invalid.";
		if (_is_instant_preview_active()) {
			err_msg += " Try disabling \"Instant Preview\" as a workaround.";
		}
		ERR_FAIL_MSG(err_msg);
	}

	item_selected_callback.call(container->get_selected());

Review comment (bug):
```suggestion
			EditorToaster::get_singleton()->popup_str(TTR("Recursion detected, Instant Preview failed."), EditorToaster::SEVERITY_ERROR);
```
Perhaps a minor nitpick, but since the functionality is referred to as "Instant Preview" in other places in the editor, I think it makes sense to use the same name here.

Code after:
void EditorQuickOpenDialog::item_pressed(bool p_double_click) {
	// A double-click should always be taken as a "confirm" action.
	if (p_double_click) {
		container->save_selected_item();
		ok_pressed();
		return;
	}

	// Single-clicks should be taken as a "confirm" action only if Instant Preview
	// isn't currently enabled, or the property object is null for some reason.
	if (!_is_instant_preview_active()) {
		container->save_selected_item();
		ok_pressed();
	}
}

void EditorQuickOpenDialog::preview_property() {
	Ref<Resource> loaded_resource = ResourceLoader::load(container->get_selected());
	ERR_FAIL_COND_MSG(loaded_resource.is_null(), "Cannot load resource from path '" + container->get_selected() + "'.");

	Resource *res = Object::cast_to<Resource>(property_object);
	if (res) {
		HashSet<Resource *> resources_found;
		resources_found.insert(res);
		if (EditorNode::find_recursive_resources(loaded_resource, resources_found)) {
			EditorToaster::get_singleton()->popup_str(TTR("Recursion detected, quick preview failed."), EditorToaster::SEVERITY_ERROR);
			loaded_resource = Ref<Resource>();
		}
	}

	// MultiNodeEdit has adding to the undo/redo stack baked into its set function.
	// As such, we have to specifically call a version of its setter that doesn't
	// create undo/redo actions.
	property_object->set_block_signals(true);
	if (Object::cast_to<MultiNodeEdit>(property_object)) {
		Object::cast_to<MultiNodeEdit>(property_object)->_set_impl(property_path, loaded_resource, "", false);
	} else {
		property_object->set(property_path, loaded_resource);
	}
	property_object->set_block_signals(false);
}

void EditorQuickOpenDialog::update_property() {
	// Set the property back to the initial value first, so that the undo action
	// has the correct object.
	if (property_object) {
		if (Object::cast_to<MultiNodeEdit>(property_object)) {
			Object::cast_to<MultiNodeEdit>(property_object)->_set_impl(property_path, initial_property_value, "", false);
		} else {
			property_object->set(property_path, initial_property_value);
		}