X Tutup
Skip to content

Fix editor log search ignoring BBCode formatting in messages#110972

Merged
Repiteo merged 1 commit intogodotengine:masterfrom
Tcarr20:fix-editor-log-bbcode-search
Oct 21, 2025
Merged

Fix editor log search ignoring BBCode formatting in messages#110972
Repiteo merged 1 commit intogodotengine:masterfrom
Tcarr20:fix-editor-log-bbcode-search

Conversation

@Tcarr20
Copy link
Contributor

@Tcarr20 Tcarr20 commented Sep 27, 2025

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.

Resolves #110967

Before searching:
image

After searching:
image

Search still works for searching specifically with bbcode syntax, and string literals representing bbcode syntax:
image

@Tcarr20 Tcarr20 requested a review from a team September 27, 2025 16:25
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it works as expected.

However, this could perhaps be implemented more efficiently with #78310 strip_bbcode() method. The downside is that you wouldn't be able to search something with its tags anymore, but I wonder how common of a use case this is to warrant the performance cost.

image image
func _ready() -> void:
	for i in ["red", "green", "cyan", "magenta", "yellow", "white"]:
		print_rich("G[b][i][shake][color=%s]owo[/color][/shake][/i][/b]dot" % i)

@Calinou Calinou added the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Sep 27, 2025
@Calinou Calinou added this to the 4.6 milestone Sep 27, 2025
@Tcarr20
Copy link
Contributor Author

Tcarr20 commented Sep 27, 2025

Tested locally, it works as expected.

However, I wonder if this could be implemented more efficiently with #78310 strip_bbcode() method. However, the downside is that you wouldn't be able to search something with its tags anymore, but I wonder how common of a use case this is to warrant the performance cost.

image image

func _ready() -> void:
	for i in ["red", "green", "cyan", "magenta", "yellow", "white"]:
		print_rich("G[b][i][shake][color=%s]owo[/color][/shake][/i][/b]dot" % i)

I thought of this as well however I did not want to assume that, those who would print with color do not want to use that as a searchable identifier. While my implementation is a little hacky, it should only use one instance of the rich text label and, it should only try to search if it can not find a match otherwise.

I also thought about removing the

p_message.text.find_char('[') != -1

as it hurts to look at.

Do you see any significant down side in just attempting to parse all of the strings that do not match immediately for bbcode?

like so:

	// If not found, also check the BBCode-parsed text
	if (!search_match) {
		// 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);
	}  
This would essentially search everything twice... 
	

@bruvzg bruvzg self-requested a review September 28, 2025 13:40
@KoBeWi
Copy link
Member

KoBeWi commented Oct 9, 2025

I think the current implementation is fine. Checking for [ ensures that expensive BBCode parsing is done only if there can be BBCode. Most messages won't be affected and checking for a single char is cheap compared to searching for match.

@Repiteo
Copy link
Contributor

Repiteo commented Oct 20, 2025

Could you squash your commits? See our pull request guidelines for more information

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.
@Tcarr20 Tcarr20 force-pushed the fix-editor-log-bbcode-search branch from 2575c89 to 5d8fae4 Compare October 21, 2025 17:03
@Repiteo Repiteo merged commit c7b1767 into godotengine:master Oct 21, 2025
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Oct 21, 2025

Thanks! Congratulations on your first merged contribution! 🎉

@akien-mga
Copy link
Member

Cherry-picked for 4.5.2.

@akien-mga akien-mga removed the cherrypick:4.5 Considered for cherry-picking into a future 4.5.x release label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTRL + F in Editor output is based on bbcode output when using print_rich()

6 participants

X Tutup