1
0
mirror of https://github.com/mfontanini/presenterm.git synced 2026-09-01 23:33:21 -06:00

fix: Overwrite current style colors when merging

with another style element to ensure that the other style is always
applied. Previously the code kept the current style if it was not
undefined, effectively disabling color styling in some scenarios like
modal dialogs.
This commit is contained in:
Andreas Hartmann 2026-02-09 07:00:37 +01:00
parent 3bc5e91945
commit 32d9ff0a32
No known key found for this signature in database
GPG Key ID: E6720298A85FBB5B
3 changed files with 10 additions and 3 deletions

View File

@ -546,7 +546,7 @@ impl<'a> InlinesParser<'a> {
}
};
style = base_style.clone();
for html_style in html_styles.iter().rev() {
for html_style in html_styles.iter() {
style.merge(&html_style.0);
}
}

View File

@ -115,11 +115,14 @@ where
}
/// Merge this style with another one.
///
/// If `other` defines a background or foreground color, that overwrites the respective color
/// in `self`.
pub(crate) fn merge(&mut self, other: &TextStyle<C>) {
self.flags |= other.flags;
self.size = self.size.max(other.size);
self.colors.background = self.colors.background.clone().or(other.colors.background.clone());
self.colors.foreground = self.colors.foreground.clone().or(other.colors.foreground.clone());
self.colors.background = other.colors.background.clone().or(self.colors.background.clone());
self.colors.foreground = other.colors.foreground.clone().or(self.colors.foreground.clone());
}
/// Return a new style merged with the one passed in.

View File

@ -235,6 +235,10 @@ struct ContentRow {
}
impl ContentRow {
/// Overwrite the style of a content row.
///
/// The current background and foreground style is overwritten with the respective definitions
/// of `style`, if they are set.
fn with_style(mut self, style: TextStyle) -> ContentRow {
for chunk in &mut self.content {
chunk.style.merge(&style);