diff --git a/assets/settings/default.json b/assets/settings/default.json index 431a6f3869926c60ca8275f19fbfaafe8a0e5097..0ff88926b2f413517a3feb8383971f248033b4a9 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -475,6 +475,10 @@ // Scroll sensitivity multiplier. This multiplier is applied // to both the horizontal and vertical delta values while scrolling. "scroll_sensitivity": 1.0, + // Scroll sensitivity multiplier for fast scrolling. This multiplier is applied + // to both the horizontal and vertical delta values while scrolling. Fast scrolling + // happens when a user holds the alt or option key while scrolling. + "fast_scroll_sensitivity": 4.0, "relative_line_numbers": false, // If 'search_wrap' is disabled, search result do not wrap around the end of the file. "search_wrap": true, diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index 080c070c5d22c1aebdcb0d4f778ba1f2fc11ed43..57459dfc94e8187e3499e9ff9f2dbfeb33318ac7 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -26,6 +26,7 @@ pub struct EditorSettings { pub autoscroll_on_clicks: bool, pub horizontal_scroll_margin: f32, pub scroll_sensitivity: f32, + pub fast_scroll_sensitivity: f32, pub relative_line_numbers: bool, pub seed_search_query_from_cursor: SeedQuerySetting, pub use_smartcase_search: bool, @@ -406,6 +407,12 @@ pub struct EditorSettingsContent { /// /// Default: 1.0 pub scroll_sensitivity: Option, + /// Scroll sensitivity multiplier for fast scrolling. This multiplier is applied + /// to both the horizontal and vertical delta values while scrolling. Fast scrolling + /// happens when a user holds the alt or option key while scrolling. + /// + /// Default: 4.0 + pub fast_scroll_sensitivity: Option, /// Whether the line numbers on editors gutter are relative or not. /// /// Default: false @@ -745,6 +752,10 @@ impl Settings for EditorSettings { "editor.mouseWheelScrollSensitivity", &mut current.scroll_sensitivity, ); + vscode.f32_setting( + "editor.fastScrollSensitivity", + &mut current.fast_scroll_sensitivity, + ); if Some("relative") == vscode.read_string("editor.lineNumbers") { current.relative_line_numbers = Some(true); } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index bdb503ab6a762b6c447bf143a433cd60a544d0a0..4050921128957f09b24d1d3cdf949fbf3e67ba0c 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -6339,9 +6339,23 @@ impl EditorElement { // Set a minimum scroll_sensitivity of 0.01 to make sure the user doesn't // accidentally turn off their scrolling. - let scroll_sensitivity = EditorSettings::get_global(cx).scroll_sensitivity.max(0.01); + let base_scroll_sensitivity = + EditorSettings::get_global(cx).scroll_sensitivity.max(0.01); + + // Use a minimum fast_scroll_sensitivity for same reason above + let fast_scroll_sensitivity = EditorSettings::get_global(cx) + .fast_scroll_sensitivity + .max(0.01); move |event: &ScrollWheelEvent, phase, window, cx| { + let scroll_sensitivity = { + if event.modifiers.alt { + fast_scroll_sensitivity + } else { + base_scroll_sensitivity + } + }; + if phase == DispatchPhase::Bubble && hitbox.is_hovered(window) { delta = delta.coalesce(event.delta); editor.update(cx, |editor, cx| {