Godot Engine – Multi-platform 2D and 3D game engine
Fix `RichTextLabel` nesting with `[font_size][p]`
kian-g76fd24073568
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cppindex eca0c5c3f77..84c809f4823 100644--- a/scene/gui/rich_text_label.cpp+++ b/scene/gui/rich_text_label.cpp@@ -3972,7 +3972,7 @@ Color RichTextLabel::_find_fgcolor(Item *p_item) {bool RichTextLabel::_find_layout_subitem(Item *from, Item *to) {if (from && from != to) {- if (from->type != ITEM_FONT && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH && from->type != ITEM_INDENT) {+ if (from->type != ITEM_FONT && from->type != ITEM_FONT_SIZE && from->type != ITEM_COLOR && from->type != ITEM_UNDERLINE && from->type != ITEM_STRIKETHROUGH && from->type != ITEM_INDENT) {return true;}diff --git a/tests/scene/test_rich_text_label.cpp b/tests/scene/test_rich_text_label.cppindex 8daf0f5eb5b..c97c394d604 100644--- a/tests/scene/test_rich_text_label.cpp+++ b/tests/scene/test_rich_text_label.cpp@@ -137,6 +137,26 @@ TEST_CASE("[SceneTree][RichTextLabel] Sizing with fit content") {memdelete(test_label);}+TEST_CASE("[SceneTree][RichTextLabel] Font size wrapping paragraph does not add empty first line") {+ RichTextLabel *test_label = memnew(RichTextLabel);+ Window *root = SceneTree::get_singleton()->get_root();+ root->add_child(test_label);++ test_label->set_use_bbcode(true);++ test_label->set_text("[p][font_size=22]aaa[/font_size][/p]");+ SceneTree::get_singleton()->process(0);+ CHECK(test_label->get_paragraph_count() == 1);+ CHECK(test_label->get_character_line(0) == 0);++ test_label->set_text("[font_size=22][p]aaa[/p][/font_size]");+ SceneTree::get_singleton()->process(0);+ CHECK(test_label->get_paragraph_count() == 1);+ CHECK(test_label->get_character_line(0) == 0);++ memdelete(test_label);+}+} // namespace TestRichTextLabel#endif // ADVANCED_GUI_DISABLED