From eec54c635bbac3dd2a2a16100694ded1088d1943 Mon Sep 17 00:00:00 2001 From: MarekSpodBiedry <73122968+MarekSpodBiedry@users.noreply.github.com> Date: Fri, 9 Oct 2026 14:48:30 +0200 Subject: [PATCH] Ctrl+-, Ctrl+= and Ctrl+0 no longer zoom the whole window (#14) (#36) egui's built-in keyboard zoom fired on the same keys as Word's shortcuts (optional hyphen, subscript, space before), so Ctrl+- looked like zoom out while it also typed an optional hyphen over the selection. Turn it off once at startup; document zoom stays under View > Zoom and the status bar. --- crates/ui-egui/src/lib.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 769ec1343a..dbf71dd616 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -300,6 +300,9 @@ impl WordApp { pub fn logic(&mut self, ctx: &egui::Context) { if !self.styled { theme::install_fonts(ctx); + // Mod with -, = and 0 are Word shortcuts (optional hyphen, subscript, paragraph spacing); + // egui's keyboard zoom would also scale the whole window on them. Zoom is View › Zoom. + ctx.options_mut(|o| o.zoom_with_keyboard = false); self.styled = true; } let dark = self.ui.dark || self.session.view.dark_mode; @@ -485,3 +488,29 @@ pub fn now_ms() -> f64 { 0.0 } } + +#[cfg(test)] +mod tests { + use super::*; + + fn mod_key(key: egui::Key) -> egui::Event { + egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::COMMAND } + } + + /// Issue #14: Mod+- (optional hyphen) also zoomed the whole window out, so it read as "zoom out". + #[test] + fn word_shortcuts_do_not_zoom_the_window() { + let ctx = egui::Context::default(); + let mut app = WordApp::new(Session::new(wordcraft_doc::Document::new()), Services::default()); + let mut frame = |events: Vec| { + let input = egui::RawInput { events, ..Default::default() }; + // No painter here: dropping the font atlas delta unapplied trips an epaint debug assertion. + ctx.run_ui(input, |ui| app.logic(ui.ctx())).drop_without_applying_deltas(); + }; + frame(Vec::new()); + frame(vec![mod_key(egui::Key::Minus)]); + frame(vec![mod_key(egui::Key::Minus)]); + frame(Vec::new()); + assert_eq!(ctx.zoom_factor(), 1.0); + } +}