From e9636f70e729f5270ec3b031703c8be3d7a615e2 Mon Sep 17 00:00:00 2001 From: Michael Alexsander Date: Fri, 1 Oct 2021 01:57:47 -0300 Subject: [PATCH] Fix `RichTextLabel` not correctly returning text with `get_text()` --- scene/gui/rich_text_label.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 277026cc28ed..2d15c39258ec 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -3891,6 +3891,19 @@ void RichTextLabel::set_text(const String &p_bbcode) { } String RichTextLabel::get_text() const { + String text = ""; + Item *it = main; + while (it) { + if (it->type == ITEM_TEXT) { + ItemText *t = static_cast(it); + text += t->text; + } else if (it->type == ITEM_NEWLINE) { + text += "\n"; + } else if (it->type == ITEM_INDENT) { + text += "\t"; + } + it = _get_next_item(it, true); + } return text; }