terminal: Add setting for scroll multiplier (#39463)

Closes #5130

Release Notes:

- Added setting option for scroll multiplier of the terminal

---------

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Co-authored-by: MrSubidubi <finn@zed.dev>
This commit is contained in:
Marco Mihai Condrache
2025-11-12 16:38:06 +01:00
committed by GitHub
co-authored by MrSubidubi
parent 80b32ddaad
commit cfbde91833
8 changed files with 63 additions and 12 deletions
+2
View File
@@ -1550,6 +1550,8 @@
// Default: 10_000, maximum: 100_000 (all bigger values set will be treated as 100_000), 0 disables the scrolling.
// Existing terminals will not pick up this change until they are recreated.
"max_scroll_history_lines": 10000,
// The multiplier for scrolling speed in the terminal.
"scroll_multiplier": 1.0,
// The minimum APCA perceptual contrast between foreground and background colors.
// APCA (Accessible Perceptual Contrast Algorithm) is more accurate than WCAG 2.x,
// especially for dark mode. Values range from 0 to 106.
@@ -116,6 +116,10 @@ pub struct TerminalSettingsContent {
///
/// Default: 10_000
pub max_scroll_history_lines: Option<usize>,
/// The multiplier for scrolling with the mouse wheel.
///
/// Default: 1.0
pub scroll_multiplier: Option<f32>,
/// Toolbar related settings
pub toolbar: Option<TerminalToolbarContent>,
/// Scrollbar-related settings
+1
View File
@@ -737,6 +737,7 @@ impl VsCodeSettings {
option_as_meta: self.read_bool("terminal.integrated.macOptionIsMeta"),
project: self.project_terminal_settings_content(),
scrollbar: None,
scroll_multiplier: None,
toolbar: None,
})
}
+18
View File
@@ -5168,6 +5168,24 @@ pub(crate) fn settings_data(cx: &App) -> Vec<SettingsPage> {
metadata: None,
files: USER,
}),
SettingsPageItem::SettingItem(SettingItem {
title: "Scroll Multiplier",
description: "The multiplier for scrolling in the terminal with the mouse wheel",
field: Box::new(SettingField {
json_path: Some("terminal.scroll_multiplier"),
pick: |settings_content| {
settings_content.terminal.as_ref()?.scroll_multiplier.as_ref()
},
write: |settings_content, value| {
settings_content
.terminal
.get_or_insert_default()
.scroll_multiplier = value;
},
}),
metadata: None,
files: USER,
}),
SettingsPageItem::SectionHeader("Toolbar"),
SettingsPageItem::SettingItem(SettingItem {
title: "Breadcrumbs",
+8 -11
View File
@@ -108,13 +108,6 @@ actions!(
]
);
///Scrolling is unbearably sluggish by default. Alacritty supports a configurable
///Scroll multiplier that is set to 3 by default. This will be removed when I
///Implement scroll bars.
#[cfg(target_os = "macos")]
const SCROLL_MULTIPLIER: f32 = 4.;
#[cfg(not(target_os = "macos"))]
const SCROLL_MULTIPLIER: f32 = 1.;
const DEBUG_TERMINAL_WIDTH: Pixels = px(500.);
const DEBUG_TERMINAL_HEIGHT: Pixels = px(30.);
const DEBUG_CELL_WIDTH: Pixels = px(5.);
@@ -1890,10 +1883,11 @@ impl Terminal {
}
///Scroll the terminal
pub fn scroll_wheel(&mut self, e: &ScrollWheelEvent) {
pub fn scroll_wheel(&mut self, e: &ScrollWheelEvent, scroll_multiplier: f32) {
let mouse_mode = self.mouse_mode(e.shift);
let scroll_multiplier = if mouse_mode { 1. } else { scroll_multiplier };
if let Some(scroll_lines) = self.determine_scroll_lines(e, mouse_mode) {
if let Some(scroll_lines) = self.determine_scroll_lines(e, scroll_multiplier) {
if mouse_mode {
let point = grid_point(
e.position - self.last_content.terminal_bounds.bounds.origin,
@@ -1926,8 +1920,11 @@ impl Terminal {
self.word_from_position(window.mouse_position());
}
fn determine_scroll_lines(&mut self, e: &ScrollWheelEvent, mouse_mode: bool) -> Option<i32> {
let scroll_multiplier = if mouse_mode { 1. } else { SCROLL_MULTIPLIER };
fn determine_scroll_lines(
&mut self,
e: &ScrollWheelEvent,
scroll_multiplier: f32,
) -> Option<i32> {
let line_height = self.last_content.terminal_bounds.line_height;
match e.touch_phase {
/* Reset scroll state on started */
+3
View File
@@ -7,6 +7,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
pub use settings::AlternateScroll;
use settings::{
RegisterSetting, ShowScrollbar, TerminalBlink, TerminalDockPosition, TerminalLineHeight,
VenvSettings, WorkingDirectory, merge_from::MergeFrom,
@@ -42,6 +43,7 @@ pub struct TerminalSettings {
pub default_height: Pixels,
pub detect_venv: VenvSettings,
pub max_scroll_history_lines: Option<usize>,
pub scroll_multiplier: f32,
pub toolbar: Toolbar,
pub scrollbar: ScrollbarSettings,
pub minimum_contrast: f32,
@@ -105,6 +107,7 @@ impl settings::Settings for TerminalSettings {
default_width: px(user_content.default_width.unwrap()),
default_height: px(user_content.default_height.unwrap()),
detect_venv: project_content.detect_venv.unwrap(),
scroll_multiplier: user_content.scroll_multiplier.unwrap(),
max_scroll_history_lines: user_content.max_scroll_history_lines,
toolbar: Toolbar {
breadcrumbs: user_content.toolbar.unwrap().breadcrumbs.unwrap(),
+6 -1
View File
@@ -519,7 +519,12 @@ impl TerminalView {
return;
}
}
self.terminal.update(cx, |term, _| term.scroll_wheel(event));
self.terminal.update(cx, |term, cx| {
term.scroll_wheel(
event,
TerminalSettings::get_global(cx).scroll_multiplier.max(0.01),
)
});
}
fn scroll_line_up(&mut self, _: &ScrollLineUp, _: &mut Window, cx: &mut Context<Self>) {
+21
View File
@@ -3586,6 +3586,7 @@ List of `integer` column numbers
"option_as_meta": false,
"button": true,
"shell": "system",
"scroll_multiplier": 3.0,
"toolbar": {
"breadcrumbs": false
},
@@ -3998,6 +3999,26 @@ Disable with:
}
```
### Terminal: Scroll Multiplier
- Description: The multiplier for scrolling speed in the terminal when using mouse wheel or trackpad.
- Setting: `scroll_multiplier`
- Default: `1.0`
**Options**
Positive floating point values. Values less than or equal to 0 will be clamped to a minimum of 0.01.
**Example**
```json
{
"terminal": {
"scroll_multiplier": 5.0
}
}
```
## Terminal: Toolbar
- Description: Whether or not to show various elements in the terminal toolbar.