R3.2: Ctrl+wheel zooms one step per notch; version 0.1.4 [skip ci]

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-12 23:15:47 -04:00
1 parent c1880288a5
commit ee1b8ad375
13 files changed
+274 -37

No files matched your search

+40
View File
@@ -425,3 +425,43 @@ fn zooming_keeps_the_pointed_spot_and_walks_the_steps() {
});
});
}
#[test]
fn ctrl_and_a_notch_zoom_one_step_about_the_pointer() {
let Some(install) = crate::client::tests::install() else {
eprintln!("SKIP: no pinned LOK build");
return;
};
let cx = gpui::TestAppContext::single();
cx.update(|app| {
let (view, _) = live_view(app, &install);
view.update(app, |view, cx| {
view.viewport = (800.0, 600.0);
view.origin = gpui::point(gpui::px(0.0), gpui::px(0.0));
view.doc_size = (60_000, 80_000);
view.scroll = (3_000, 9_000);
view.set_zoom(1.0, cx);
let at = gpui::point(gpui::px(300.0), gpui::px(200.0));
let wheel = |modifiers, y| gpui::ScrollWheelEvent {
position: at,
delta: gpui::ScrollDelta::Lines(gpui::point(0.0, y)),
modifiers,
..Default::default()
};
let other = match cfg!(target_os = "macos") {
true => gpui::Modifiers { control: true, ..Default::default() },
false => gpui::Modifiers { platform: true, ..Default::default() },
};
assert!(!view.wheel_zoom(&wheel(other, 3.0), cx), "only Ctrl, or Cmd on macOS");
assert_eq!(view.zoom(), 1.0);
let spot = |view: &LokView| view.scroll.1 + view.geom.twips_of(200.0);
let before = spot(view);
assert!(view.wheel_zoom(&wheel(gpui::Modifiers::secondary_key(), 3.0), cx));
assert_eq!(view.zoom(), 1.25, "a three-line notch is one step");
assert!((spot(view) - before).abs() <= 1, "the pointed spot stays");
view.wheel_zoom(&wheel(gpui::Modifiers::secondary_key(), -1.0), cx);
view.wheel_zoom(&wheel(gpui::Modifiers::secondary_key(), -1.0), cx);
assert_eq!(view.zoom(), 0.8);
});
});
}