Merge #986: fix: = zooms in, matching - zooming out (#973) (@Ridzzz0Alam)

This commit is contained in:
bflatastic
2026-10-24 09:13:43 +07:00
3 changed files with 25 additions and 4 deletions
+4 -2
View File
@@ -229,8 +229,10 @@ pub static KEYS: &[Binding] = &[
k(View, "view.prevPage", &["PageUp"]),
k(View, "view.nextPage", &["PageDown"]),
// Zoom
k(Zoom, "view.zoomIn", &["Cmd+=", "Shift+=", "Shift+Cmd+="]),
k(Zoom, "view.zoomOut", &["Cmd+-", "-", "Shift+-"]),
// Each zoom-in key has its zoom-out twin on the key beside it: `-` alone zooms out, so `=`
// alone (the `+` key without Shift) zooms in (#973).
k(Zoom, "view.zoomIn", &["Cmd+=", "Shift+=", "Shift+Cmd+=", "="]),
k(Zoom, "view.zoomOut", &["Cmd+-", "-", "Shift+-", "Shift+Cmd+-"]),
k(Zoom, "view.zoom100", &["Shift+0", "Cmd+0"]),
k(Zoom, "view.zoomFit", &["Shift+1"]),
k(Zoom, "view.zoomSelection", &["Shift+2"]),
+19
View File
@@ -168,6 +168,25 @@ fn display_per_platform() {
assert_eq!(primary("polygon.none", mac), None);
}
/// Each way of zooming in has its zoom-out twin on the key beside it, as the keys arrive from a US
/// keyboard (#973: `-` alone zoomed out but `=` alone did nothing, so zooming back in was stuck).
#[test]
fn zoom_keys_come_in_pairs() {
let none = Mods::default();
let shift = mods(true, false, false, false);
let cmd = mods(false, false, true, false);
let shift_cmd = mods(true, false, true, false);
for p in PLATFORMS {
for (zoom_in, zoom_out, m) in [("Equals", "Minus", none), ("Equals", "Minus", cmd), ("Plus", "Minus", shift_cmd), ("Plus", "Minus", shift)] {
assert_eq!(id_for(p, Context::Canvas, zoom_in, m), Some("view.zoomIn"), "{zoom_in} {m:?} on {p:?}");
assert_eq!(id_for(p, Context::Canvas, zoom_out, m), Some("view.zoomOut"), "{zoom_out} {m:?} on {p:?}");
}
// The menus still show Cmd/Ctrl and `+`.
assert_eq!(primary("view.zoomIn", p), Some("Cmd+="));
assert_eq!(primary("view.zoomOut", p), Some("Cmd+-"));
}
}
#[test]
fn tool_keys_come_from_the_keymap() {
assert_eq!(ToolId::Move.shortcut(), "V");
+2 -2
View File
@@ -171,8 +171,8 @@ static ROWS: &[Row] = &[
doc(Zoom, "Zoom out", &["Cmd+-", "-"], &[], Bound("view.zoomOut"), ""),
doc(Zoom, "Zoom to fit", &["Shift+1"], &[], Bound("view.zoomFit"), ""),
doc(Zoom, "Zoom to the selection", &["Shift+2"], &[], Bound("view.zoomSelection"), ""),
pin(Zoom, "view.zoomIn", &["Shift+Cmd+="], &[]),
pin(Zoom, "view.zoomOut", &["Shift+-"], &[]),
pin(Zoom, "view.zoomIn", &["Shift+Cmd+=", "="], &[]),
pin(Zoom, "view.zoomOut", &["Shift+-", "Shift+Cmd+-"], &[]),
pin(Zoom, "view.zoom100", &["Shift+0", "Cmd+0"], &[]),
pin(Zoom, "view.prevFrame", &["Shift+N", "Home"], &[]),
pin(Zoom, "view.nextFrame", &["N", "End"], &[]),