mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 22:08:42 +00:00
Keep a styles-panel highlight made before the panel first drew
A highlight set by a panel action before the list ever drew had no document yet, so the next draw dropped it; such a panel now takes the active document.
This commit is contained in:
@@ -81,13 +81,15 @@ pub(crate) struct StylesPanel {
|
||||
}
|
||||
|
||||
/// The styles highlighted in the panel, in the order they were picked, among the styles `listed`; a
|
||||
/// highlight made in another document is dropped.
|
||||
/// highlight made in another document is dropped. A highlight made before the panel first read one (an
|
||||
/// action from the panel menu before the list drew) is the active document's.
|
||||
fn highlighted(app: &mut VectorcraftApp, kind: Kind, listed: &[&str]) -> Vec<String> {
|
||||
let document = app.session.active().map(|st| st.uid);
|
||||
let panel = app.ui.text_styles.of(kind);
|
||||
if panel.document != document {
|
||||
*panel = StylesPanel { document, ..Default::default() };
|
||||
if panel.document.is_some_and(|made| Some(made) != document) {
|
||||
*panel = StylesPanel::default();
|
||||
}
|
||||
panel.document = document;
|
||||
panel.highlight.retain(|n| listed.contains(&n.as_str()));
|
||||
panel.highlight.clone()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user