diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs index eb0b8f8b71..82496a6821 100644 --- a/crates/engine/src/commands.rs +++ b/crates/engine/src/commands.rs @@ -276,7 +276,7 @@ pub const COMMANDS: &[CommandSpec] = &[ c("view.theme.system", "Use system setting", None, None, Nothing, "settings"), c("view.theme.light", "Light gray", None, None, Nothing, "sun"), c("view.theme.dark", "Dark gray", None, None, Nothing, "moon"), - c("comment.list", "Comments panel", VIEW, None, Document, "message-square-text"), + c("comment.list", "Comments panel", VIEW, Some(Shortcut::cmd("M")), Document, "message-square-text"), c("comment.note", "Add a sticky note", None, None, Annotate, "sticky-note"), c("comment.freetext", "Add a text box", None, None, Annotate, "type"), c("comment.highlight", "Highlight text", None, None, Annotate, "highlighter"), @@ -523,6 +523,7 @@ mod tests { assert_eq!(s.label(true), "⇧⌘S"); assert_eq!(s.label(false), "Ctrl+Shift+S"); assert_eq!(command("view.read_mode").unwrap().shortcut.unwrap().label(true), "⌃⌘H"); + assert_eq!(command("comment.list").unwrap().shortcut.unwrap().label(false), "Ctrl+M"); assert_eq!(Shortcut::cmd("+").label(false), "Ctrl++"); assert_eq!(Shortcut::cmd_shift("−").label(true), "⇧⌘−"); assert_eq!(Shortcut::cmd_shift("−").label(false), "Ctrl+Shift+−"); diff --git a/crates/ui-egui/tests/it/commands.rs b/crates/ui-egui/tests/it/commands.rs index 2dceb7a59a..2b2603ca37 100644 --- a/crates/ui-egui/tests/it/commands.rs +++ b/crates/ui-egui/tests/it/commands.rs @@ -282,6 +282,24 @@ fn shortcuts_run_registered_commands() { assert_eq!(h.state().mode, pdfcraft_ui_egui::Mode::Read); } +#[test] +fn ctrl_m_opens_the_comments_panel_and_keeps_it_open() { + let mut h = harness(); + h.state_mut().right = None; + h.run_steps(2); + h.key_press_modifiers(Modifiers::COMMAND, Key::M); + h.run_steps(2); + assert_eq!(h.state().right, Some(pdfcraft_ui_egui::RightPanel::Comments)); + // Pressed again it opens, not toggles (#3741). + h.key_press_modifiers(Modifiers::COMMAND, Key::M); + h.run_steps(2); + assert_eq!(h.state().right, Some(pdfcraft_ui_egui::RightPanel::Comments)); + h.ctx.set_os(OperatingSystem::Nix); + h.state_mut().execute("help.shortcuts"); + h.run_steps(3); + h.get_by_label("Ctrl+M"); +} + #[test] fn the_palette_lists_commands_with_shortcuts_and_runs_them() { let mut h = harness();