Skip to content

Commit c7b1767

Browse files
committed
Merge pull request #110972 from Tcarr20/fix-editor-log-bbcode-search
Fix editor log search ignoring BBCode formatting in messages
2 parents 10506f8 + 5d8fae4 commit c7b1767

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

editor/editor_log.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,28 @@ void EditorLog::_rebuild_log() {
341341
bool EditorLog::_check_display_message(LogMessage &p_message) {
342342
bool filter_active = type_filter_map[p_message.type]->is_active();
343343
String search_text = search_box->get_text();
344-
bool search_match = search_text.is_empty() || p_message.text.containsn(search_text);
344+
345+
if (search_text.is_empty()) {
346+
return filter_active;
347+
}
348+
349+
bool search_match = p_message.text.containsn(search_text);
350+
351+
// If not found and message contains BBCode tags, also check the parsed text
352+
if (!search_match && p_message.text.contains_char('[')) {
353+
// Lazy initialize the BBCode parser
354+
if (!bbcode_parser) {
355+
bbcode_parser = memnew(RichTextLabel);
356+
bbcode_parser->set_use_bbcode(true);
357+
}
358+
359+
// Ensure clean state for each message
360+
bbcode_parser->clear();
361+
bbcode_parser->parse_bbcode(p_message.text);
362+
String parsed_text = bbcode_parser->get_parsed_text();
363+
search_match = parsed_text.containsn(search_text);
364+
}
365+
345366
return filter_active && search_match;
346367
}
347368

@@ -586,6 +607,10 @@ void EditorLog::deinit() {
586607
}
587608

588609
EditorLog::~EditorLog() {
610+
if (bbcode_parser) {
611+
memdelete(bbcode_parser);
612+
}
613+
589614
for (const KeyValue<MessageType, LogFilter *> &E : type_filter_map) {
590615
// MSG_TYPE_STD_RICH is connected to the std_filter button, so we do this
591616
// to avoid it from being deleted twice, causing a crash on closing.

editor/editor_log.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ class EditorLog : public HBoxContainer {
140140
Button *show_search_button = nullptr;
141141
LineEdit *search_box = nullptr;
142142

143+
// Reusable RichTextLabel for BBCode parsing during search
144+
RichTextLabel *bbcode_parser = nullptr;
145+
143146
// Reference to the "Output" button on the toolbar so we can update its icon when warnings or errors are encountered.
144147
Button *tool_button = nullptr;
145148

0 commit comments

Comments
 (0)