Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Fix styled text highlight crash #78

Merged
merged 3 commits into from
Mar 23, 2024

Conversation

ashlikatt
Copy link

@ashlikatt ashlikatt commented Mar 23, 2024

Crash occurred when writing <hover:show_text:'> due to the expression being invalid and the fail-safe formatting not implementing BuildableComponent like the syntax highlighter expects.

resolves Issue

MiniMessageHighlighter::highlight's fail-safe returned a ComponentLike that could not be cast to a BuildableComponent by ExpressionHighlighting::highlightUncached, crashing the game. The fix changes that fail-safe to return a Component (which implements BuildableComponent).

I figured it's better to fix the issue in the styled-text specific code because MiniMessageHighlighter expects BuildableComponents and nothing else seems to violate that.

Fail-safe highlighting working properly:
image

Ashli Katt added 2 commits March 23, 2024 17:56
MiniMessageHighlighter::highlight may return a value that wasn't able to cast into a BuildableComponent.

It may be better to move the check to the call-site in ExpressionHighlighting instead? Seems like more of an issue with MiniMessageHighlighter, though, because it's more specific to styled text.
Copy link
Owner

@homchom homchom left a comment

Choose a reason for hiding this comment

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

Nice catch, thank you for looking into this. Could you also change the return type of highlight to Component instead of ComponentLike?

…nt` to prevent possible future cast errors
@homchom homchom merged commit c54eaff into homchom:main Mar 23, 2024
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not closing show_text quote leads to a crash
2 participants