Ctrl+M opens the Comments panel (#3741)

Bind comment.list to Ctrl+M (Cmd+M on macOS). The command opens the
panel rather than toggling it, so pressing it with the panel already
open keeps it open. The binding comes from the command registry, so the
View menu, the palette and Help > Keyboard shortcuts show it.
This commit is contained in:
Adrian committed 2026-11-16 04:27:47 -05:00
1 parent 75a6ce50c3
commit fdf9350045
2 files changed
+20 -1

No files matched your search

+2 -1
View File
@@ -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+−");
+18
View File
@@ -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();