gpui: Make refining a Style properly refine the TextStyle
#42852
+72
−101
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivating problem
The gpui API currently has this counter intuitive behaviour
By changing the text_color when the div is active, the current behaviour is to overwrite all of the text styling rather than do a proper refinement of the existing text styling leading to this odd result:
The button being active inadvertently changes the font size.
Screen.Recording.2025-11-16.at.10.51.32.pm.mov
Solution
Previously refining a Style would not recursively refine the TextStyle inside of it, leading to this behaviour:
(As best as I can tell) Style deliberately has
pub text: TextStyleRefinementstoring theTextStyleRefinementrather than the absoluteTextStyleso that these refinements can be elsewhere used in cascading text styles down to element's children. But a consequence of that is that the refine macro was not properly recursively refining thetextfield as it ought to.I've modified the refine macro so that the
#[refineable]attribute works withTextStyleRefinementas well as the usualTextStyle. (Perhaps a little bit haphazardly by simply checking whether the name ends in Refinement - there may be a better solution there).This PR resolves the motivating problem and triggers the assertion in the above code as you'd expect. I've compiled zed under these changes and all seems to be in order there.
Release Notes: