Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/agent_ui/src/agent_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl AgentDiffPane {
editor
.set_render_diff_hunk_controls(diff_hunk_controls(&thread, workspace.clone()), cx);
editor.register_addon(AgentDiffAddon);
editor.disable_mouse_wheel_zoom();
editor
});

Expand Down
1 change: 1 addition & 0 deletions crates/agent_ui/src/conversation_view/thread_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5170,6 +5170,7 @@ impl ThreadView {
let mut editor =
Editor::for_multibuffer(buffer, Some(project.clone()), window, cx);
editor.set_breadcrumb_header(thread_title);
editor.disable_mouse_wheel_zoom();
editor
})),
None,
Expand Down
1 change: 1 addition & 0 deletions crates/agent_ui/src/inline_assistant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ impl InlineAssistant {
editor.set_show_wrap_guides(false, cx);
editor.set_show_gutter(false, cx);
editor.set_offset_content(false, cx);
editor.disable_mouse_wheel_zoom();
editor.scroll_manager.set_forbid_vertical_scroll(true);
editor.set_read_only(true);
editor.set_show_edit_predictions(Some(false), window, cx);
Expand Down
1 change: 1 addition & 0 deletions crates/agent_ui/src/message_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ impl MessageEditor {
editor.set_show_indent_guides(false, cx);
editor.set_show_completions_on_input(Some(true));
editor.set_soft_wrap();
editor.disable_mouse_wheel_zoom();
editor.set_use_modal_editing(true);
editor.set_context_menu_options(ContextMenuOptions {
min_entries_visible: 12,
Expand Down
1 change: 1 addition & 0 deletions crates/debugger_ui/src/session/running/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl Console {
editor.set_show_indent_guides(false, cx);
editor.set_show_edit_predictions(Some(false), window, cx);
editor.set_use_modal_editing(false);
editor.disable_mouse_wheel_zoom();
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
editor
});
Expand Down
13 changes: 11 additions & 2 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ pub struct Editor {
delegate_open_excerpts: bool,
enable_lsp_data: bool,
enable_runnables: bool,
enable_mouse_wheel_zoom: bool,
show_line_numbers: Option<bool>,
use_relative_line_numbers: Option<bool>,
show_git_diff_gutter: Option<bool>,
Expand Down Expand Up @@ -1972,6 +1973,9 @@ impl Editor {
clone.read_only = self.read_only;
clone.buffers_with_disabled_indent_guides =
self.buffers_with_disabled_indent_guides.clone();
clone.enable_mouse_wheel_zoom = self.enable_mouse_wheel_zoom;
clone.enable_lsp_data = self.enable_lsp_data;
clone.enable_runnables = self.enable_runnables;
clone
}

Expand Down Expand Up @@ -2419,8 +2423,9 @@ impl Editor {
delegate_expand_excerpts: false,
delegate_stage_and_restore: false,
delegate_open_excerpts: false,
enable_lsp_data: true,
enable_runnables: true,
enable_lsp_data: full_mode,
enable_runnables: full_mode,
enable_mouse_wheel_zoom: full_mode,
show_git_diff_gutter: None,
show_code_actions: None,
show_runnables: None,
Expand Down Expand Up @@ -26082,6 +26087,10 @@ impl Editor {
self.enable_runnables = false;
}

pub fn disable_mouse_wheel_zoom(&mut self) {
self.enable_mouse_wheel_zoom = false;
}

fn update_data_on_scroll(&mut self, window: &mut Window, cx: &mut Context<'_, Self>) {
self.register_visible_buffers(cx);
self.colorize_brackets(false, cx);
Expand Down
17 changes: 5 additions & 12 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7673,22 +7673,18 @@ impl EditorElement {

move |event: &ScrollWheelEvent, phase, window, cx| {
if phase == DispatchPhase::Bubble && hitbox.should_handle_scroll(window) {
if event.modifiers.secondary() {
delta = delta.coalesce(event.delta);

if event.modifiers.secondary() && editor.read(cx).enable_mouse_wheel_zoom {
let delta_y = match event.delta {
ScrollDelta::Pixels(pixels) => pixels.y.into(),
ScrollDelta::Lines(lines) => lines.y,
};

if delta_y > 0.0 {
window.dispatch_action(
Box::new(zed_actions::IncreaseBufferFontSize { persist: false }),
cx,
);
theme_settings::increase_buffer_font_size(cx);
} else if delta_y < 0.0 {
window.dispatch_action(
Box::new(zed_actions::DecreaseBufferFontSize { persist: false }),
cx,
);
theme_settings::decrease_buffer_font_size(cx);
}

cx.stop_propagation();
Expand All @@ -7701,10 +7697,7 @@ impl EditorElement {
}
};

delta = delta.coalesce(event.delta);
editor.update(cx, |editor, cx| {
let position_map: &PositionMap = &position_map;

let line_height = position_map.line_height;
let glyph_width = position_map.em_layout_width;
let (delta, axis) = match delta {
Expand Down
1 change: 1 addition & 0 deletions crates/inspector_ui/src/div_inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ impl DivInspector {
editor.set_show_breakpoints(false, cx);
editor.set_show_git_diff_gutter(false, cx);
editor.set_show_runnables(false, cx);
editor.disable_mouse_wheel_zoom();
editor.set_show_edit_predictions(Some(false), window, cx);
editor.set_minimap_visibility(MinimapVisibility::Disabled, window, cx);
editor
Expand Down
1 change: 1 addition & 0 deletions crates/keymap_editor/src/keymap_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3318,6 +3318,7 @@ impl ActionArgumentsEditor {
window,
cx,
);
editor.disable_mouse_wheel_zoom();
editor.set_searchable(false);
editor.disable_scrollbars_and_minimap(window, cx);
editor.set_show_edit_predictions(Some(false), window, cx);
Expand Down
3 changes: 3 additions & 0 deletions crates/repl/src/notebook/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ impl MarkdownCell {
editor.set_show_gutter(false, cx);
editor.set_text_style_refinement(refinement);
editor.set_use_modal_editing(true);
editor.disable_mouse_wheel_zoom();
editor
});

Expand Down Expand Up @@ -641,6 +642,7 @@ impl CodeCell {
..Default::default()
};

editor.disable_mouse_wheel_zoom();
editor.set_show_gutter(false, cx);
editor.set_text_style_refinement(refinement);
editor.set_use_modal_editing(true);
Expand Down Expand Up @@ -718,6 +720,7 @@ impl CodeCell {
..Default::default()
};

editor.disable_mouse_wheel_zoom();
editor.set_text(source.clone(), window, cx);
editor.set_show_gutter(false, cx);
editor.set_text_style_refinement(refinement);
Expand Down
3 changes: 2 additions & 1 deletion crates/theme_settings/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ pub fn adjusted_font_size(size: Pixels, cx: &App) -> Pixels {
clamp_font_size(adjusted_font_size)
}

/// Adjusts the buffer font size.
/// Adjusts the buffer font size, without persisting the result in the settings.
/// This will be effective until the app is restarted.
pub fn adjust_buffer_font_size(cx: &mut App, f: impl FnOnce(Pixels) -> Pixels) {
let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;
let adjusted_size = cx
Expand Down
19 changes: 16 additions & 3 deletions crates/theme_settings/src/theme_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::sync::Arc;

use ::settings::{IntoGpui, Settings, SettingsStore};
use anyhow::{Context as _, Result};
use gpui::{App, Font, HighlightStyle, Pixels, Refineable};
use gpui::{App, Font, HighlightStyle, Pixels, Refineable, px};
use gpui_util::ResultExt;
use theme::{
AccentColors, Appearance, AppearanceContent, DEFAULT_DARK_THEME, DEFAULT_ICON_THEME_NAME,
Expand All @@ -26,11 +26,12 @@ pub use crate::schema::{
ThemeColorsContent, ThemeContent, ThemeFamilyContent, ThemeStyleContent,
WindowBackgroundContent, status_colors_refinement, syntax_overrides, theme_colors_refinement,
};
use crate::settings::adjust_buffer_font_size;
pub use crate::settings::{
AgentFontSize, BufferLineHeight, FontFamilyName, IconThemeName, IconThemeSelection,
ThemeAppearanceMode, ThemeName, ThemeSelection, ThemeSettings, adjust_agent_buffer_font_size,
adjust_agent_ui_font_size, adjust_buffer_font_size, adjust_ui_font_size, adjusted_font_size,
appearance_to_mode, clamp_font_size, default_theme, observe_buffer_font_size_adjustment,
adjust_agent_ui_font_size, adjust_ui_font_size, adjusted_font_size, appearance_to_mode,
clamp_font_size, default_theme, observe_buffer_font_size_adjustment,
reset_agent_buffer_font_size, reset_agent_ui_font_size, reset_buffer_font_size,
reset_ui_font_size, set_icon_theme, set_mode, set_theme, setup_ui_font,
};
Expand Down Expand Up @@ -410,3 +411,15 @@ pub fn merge_accent_colors(
accent_colors.0 = Arc::from(colors);
}
}

/// Increases the buffer font size by 1 pixel, without persisting the result in the settings.
/// This will be effective until the app is restarted.
pub fn increase_buffer_font_size(cx: &mut App) {
adjust_buffer_font_size(cx, |size| size + px(1.0));
}

/// Decreases the buffer font size by 1 pixel, without persisting the result in the settings.
/// This will be effective until the app is restarted.
pub fn decrease_buffer_font_size(cx: &mut App) {
adjust_buffer_font_size(cx, |size| size - px(1.0));
}
4 changes: 2 additions & 2 deletions crates/zed/src/zed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ fn register_actions(
.insert(f32::from(theme_settings::clamp_font_size(buffer_font_size)).into());
});
} else {
theme_settings::adjust_buffer_font_size(cx, |size| size + px(1.0));
theme_settings::increase_buffer_font_size(cx);
}
}
})
Expand All @@ -945,7 +945,7 @@ fn register_actions(
.insert(f32::from(theme_settings::clamp_font_size(buffer_font_size)).into());
});
} else {
theme_settings::adjust_buffer_font_size(cx, |size| size - px(1.0));
theme_settings::decrease_buffer_font_size(cx);
}
}
})
Expand Down
Loading