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:
parent
3bc5e91945
commit
32d9ff0a32
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user