diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 8ad20d22442..79ac8f12cbb 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -341,7 +341,28 @@ void EditorLog::_rebuild_log() { bool EditorLog::_check_display_message(LogMessage &p_message) { bool filter_active = type_filter_map[p_message.type]->is_active(); String search_text = search_box->get_text(); - bool search_match = search_text.is_empty() || p_message.text.containsn(search_text); + + if (search_text.is_empty()) { + return filter_active; + } + + bool search_match = p_message.text.containsn(search_text); + + // If not found and message contains BBCode tags, also check the parsed text + if (!search_match && p_message.text.contains_char('[')) { + // Lazy initialize the BBCode parser + if (!bbcode_parser) { + bbcode_parser = memnew(RichTextLabel); + bbcode_parser->set_use_bbcode(true); + } + + // Ensure clean state for each message + bbcode_parser->clear(); + bbcode_parser->parse_bbcode(p_message.text); + String parsed_text = bbcode_parser->get_parsed_text(); + search_match = parsed_text.containsn(search_text); + } + return filter_active && search_match; } @@ -586,6 +607,10 @@ void EditorLog::deinit() { } EditorLog::~EditorLog() { + if (bbcode_parser) { + memdelete(bbcode_parser); + } + for (const KeyValue &E : type_filter_map) { // MSG_TYPE_STD_RICH is connected to the std_filter button, so we do this // to avoid it from being deleted twice, causing a crash on closing. diff --git a/editor/editor_log.h b/editor/editor_log.h index 444b943b1fb..8888ff3d481 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -140,6 +140,9 @@ private: Button *show_search_button = nullptr; LineEdit *search_box = nullptr; + // Reusable RichTextLabel for BBCode parsing during search + RichTextLabel *bbcode_parser = nullptr; + // Reference to the "Output" button on the toolbar so we can update its icon when warnings or errors are encountered. Button *tool_button = nullptr;