1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-03 11:50:27 +00:00

Fix editor log search ignoring BBCode formatting in messages

When searching in the editor output log, messages with BBCode formatting
(like [color=red]text[/color]) would not be found when searching for the
plain text content. For example, searching for "Example is" in a message
"[color=blue]EXAMPLE[/color] is super cool" would fail to find the match.
This commit is contained in:
Anthony Carr
2025-09-27 11:10:41 -05:00
parent 7864ac8019
commit 5d8fae428e
2 changed files with 29 additions and 1 deletions

View File

@@ -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<MessageType, LogFilter *> &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.

View File

@@ -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;