From cb6703c0f106b60f5db565fdc1d89a1bff4f7b22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:58:15 -0800 Subject: [PATCH] Menus: an interaction a dialog or the font menu begins reads the menus CI failed `the_font_menu_preview_reads_the_menus_when_it_ends`: with the state key holding the revision an interaction began from, the key no longer changed when the font menu's preview began, so the menus were not read then, though commands that check for an open interaction change state at that point and the menu stays open while it previews. The key now also holds whether an interaction that the active tool did not begin is open. A tool's drag still keeps the key as it begins; a dialog's, a panel's or the font menu's preview changes it as it begins and as it ends. `Interaction::by_tool` reads the flag for the UI crate. --- crates/engine/src/interaction.rs | 7 +++++++ crates/ui-egui/src/menus/model.rs | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/interaction.rs b/crates/engine/src/interaction.rs index bdc829fb37..387fc0e009 100644 --- a/crates/engine/src/interaction.rs +++ b/crates/engine/src/interaction.rs @@ -55,6 +55,13 @@ pub struct Interaction { pub keep_on_switch: bool, } +impl Interaction { + /// The active tool began it (a drag). + pub fn by_tool(&self) -> bool { + self.tool + } +} + /// An interaction that a command from outside the tool set aside while it runs /// ([`crate::Session::outside_interaction`]). #[derive(Debug)] diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 92c1786af4..dc4357363b 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -90,7 +90,9 @@ pub(crate) fn translate_label(english: &'static str) -> String { /// doesn't list (panels shown, a tool picked). While an /// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's /// preview, or a typing session), the hash takes the revision the interaction began from in place of the current one, -/// which each of its previews changes: the hash stays the same as the interaction begins, and changes as it ends. +/// which each of its previews changes, and changes as it ends. The hash stays the same as a tool's drag begins. An +/// interaction that a dialog, a panel or the font menu begins changes the hash as it begins, since commands that check +/// for an open interaction change state then and the menus stay open while it previews. pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { let mut h = DefaultHasher::new(); input.hash(&mut h); @@ -102,7 +104,8 @@ pub(crate) fn state_key(app: &VectorcraftApp, input: Option) -> u64 { (s.journal.len(), s.active_index(), s.clipboard.is_empty(), s.tool_composing()).hash(&mut h); if let Some(d) = s.active() { let revision = d.interaction.as_ref().map_or(d.revision, |it| it.revision); - (d.uid, revision, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h); + let previewing = d.interaction.as_ref().is_some_and(|it| !it.by_tool()); + (d.uid, revision, previewing, d.history.undo.len(), d.history.redo.len(), d.transparency_grid, d.print_tiling).hash(&mut h); } (app.system_paste, app.last_effect.is_some(), app.ui.recent_files.len(), app.ui.recent_files.first(), app.recent_fonts().len()).hash(&mut h); // Apply Last Filter and Last Filter… are named after the filter that ran last.