# Objective - Fixes #62645 ## Solution Since the default value isnt constant.It now has two options 1) Default 2) custom where user inputs a value. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [ ] Performance impact has been considered and is acceptable ## Showcase <img width="798" height="361" alt="Screenshot 2026-08-16 at 4 29 54 PM" src="https://github.com/user-attachments/assets/0af302f6-4733-4a23-9e93-1f9d98dd772f" /> <img width="798" height="92" alt="Screenshot 2026-08-16 at 4 30 13 PM" src="https://github.com/user-attachments/assets/2c87c2a3-2947-45c7-8495-f6a0b36dd793" /> Release Notes: - Added git_gutter_width setting to the Settings UI with default (font-size-scaled) and custom (fixed pixel width) options --------- Co-authored-by: Abdul Rafey Ahmed <abdul.r@hyperverge.co> Co-authored-by: MrSubidubi <finn@zed.dev>
219 lines
8.7 KiB
Rust
219 lines
8.7 KiB
Rust
use std::{num::NonZeroUsize, time::Duration};
|
|
|
|
use crate::DockPosition;
|
|
use collections::HashMap;
|
|
use gpui::{App, Subscription};
|
|
use serde::Deserialize;
|
|
pub use settings::{
|
|
AutosaveSetting, BottomDockLayout, EncodingDisplayOptions, InactiveOpacity,
|
|
PaneSplitDirectionHorizontal, PaneSplitDirectionVertical, RegisterSetting,
|
|
RestoreOnStartupBehavior, Settings,
|
|
};
|
|
use settings::{CommandAliasTarget, SettingsStore};
|
|
|
|
#[derive(RegisterSetting)]
|
|
pub struct WorkspaceSettings {
|
|
pub active_pane_modifiers: ActivePanelModifiers,
|
|
pub bottom_dock_layout: settings::BottomDockLayout,
|
|
pub pane_split_direction_horizontal: settings::PaneSplitDirectionHorizontal,
|
|
pub pane_split_direction_vertical: settings::PaneSplitDirectionVertical,
|
|
pub centered_layout: settings::CenteredLayoutSettings,
|
|
pub confirm_quit: bool,
|
|
pub show_call_status_icon: bool,
|
|
pub autosave: AutosaveSetting,
|
|
pub restore_on_startup: settings::RestoreOnStartupBehavior,
|
|
pub cli_default_open_behavior: settings::CliDefaultOpenBehavior,
|
|
pub default_open_behavior: settings::DefaultOpenBehavior,
|
|
pub restore_on_file_reopen: bool,
|
|
pub drop_target_size: f32,
|
|
pub use_system_path_prompts: bool,
|
|
pub use_system_prompts: bool,
|
|
pub accessible_mode: bool,
|
|
pub command_aliases: HashMap<String, CommandAliasTarget>,
|
|
pub max_tabs: Option<NonZeroUsize>,
|
|
pub when_closing_with_no_tabs: settings::CloseWindowWhenNoItems,
|
|
pub on_last_window_closed: settings::OnLastWindowClosed,
|
|
pub text_rendering_mode: settings::TextRenderingMode,
|
|
pub resize_all_panels_in_dock: Vec<DockPosition>,
|
|
pub close_on_file_delete: bool,
|
|
pub close_panel_on_toggle: bool,
|
|
pub use_system_window_tabs: bool,
|
|
pub fullscreen_mode: settings::FullscreenMode,
|
|
pub zoomed_padding: bool,
|
|
pub window_decorations: settings::WindowDecorations,
|
|
pub focus_follows_mouse: FocusFollowsMouse,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Deserialize)]
|
|
pub struct FocusFollowsMouse {
|
|
pub enabled: bool,
|
|
pub debounce: Duration,
|
|
}
|
|
|
|
#[derive(Copy, Clone, PartialEq, Debug, Default)]
|
|
pub struct ActivePanelModifiers {
|
|
/// Size of the border surrounding the active pane.
|
|
/// When set to 0, the active pane doesn't have any border.
|
|
/// The border is drawn inset.
|
|
///
|
|
/// Default: `0.0`
|
|
// TODO: make this not an option, it is never None
|
|
pub border_size: Option<f32>,
|
|
/// Opacity of inactive panels.
|
|
/// When set to 1.0, the inactive panes have the same opacity as the active one.
|
|
/// If set to 0, the inactive panes content will not be visible at all.
|
|
/// Values are clamped to the [0.0, 1.0] range.
|
|
///
|
|
/// Default: `1.0`
|
|
// TODO: make this not an option, it is never None
|
|
pub inactive_opacity: Option<InactiveOpacity>,
|
|
}
|
|
|
|
#[derive(Deserialize, RegisterSetting)]
|
|
pub struct TabBarSettings {
|
|
pub show: bool,
|
|
pub show_nav_history_buttons: bool,
|
|
pub show_tab_bar_buttons: bool,
|
|
pub show_pinned_tabs_in_separate_row: bool,
|
|
}
|
|
|
|
impl Settings for WorkspaceSettings {
|
|
fn from_settings(content: &settings::SettingsContent) -> Self {
|
|
let workspace = &content.workspace;
|
|
Self {
|
|
active_pane_modifiers: ActivePanelModifiers {
|
|
border_size: Some(
|
|
*workspace
|
|
.active_pane_modifiers
|
|
.unwrap()
|
|
.border_size
|
|
.unwrap(),
|
|
),
|
|
inactive_opacity: Some(
|
|
workspace
|
|
.active_pane_modifiers
|
|
.unwrap()
|
|
.inactive_opacity
|
|
.unwrap(),
|
|
),
|
|
},
|
|
bottom_dock_layout: workspace.bottom_dock_layout.unwrap(),
|
|
pane_split_direction_horizontal: workspace.pane_split_direction_horizontal.unwrap(),
|
|
pane_split_direction_vertical: workspace.pane_split_direction_vertical.unwrap(),
|
|
centered_layout: workspace.centered_layout.unwrap(),
|
|
confirm_quit: workspace.confirm_quit.unwrap(),
|
|
show_call_status_icon: workspace.show_call_status_icon.unwrap(),
|
|
autosave: workspace.autosave.unwrap(),
|
|
restore_on_startup: workspace.restore_on_startup.unwrap(),
|
|
cli_default_open_behavior: workspace.cli_default_open_behavior.unwrap(),
|
|
default_open_behavior: workspace.default_open_behavior.unwrap(),
|
|
restore_on_file_reopen: workspace.restore_on_file_reopen.unwrap(),
|
|
drop_target_size: workspace.drop_target_size.unwrap(),
|
|
use_system_path_prompts: workspace.use_system_path_prompts.unwrap(),
|
|
use_system_prompts: workspace.use_system_prompts.unwrap(),
|
|
accessible_mode: workspace.accessible_mode.unwrap(),
|
|
command_aliases: workspace.command_aliases.clone(),
|
|
max_tabs: workspace.max_tabs,
|
|
when_closing_with_no_tabs: workspace.when_closing_with_no_tabs.unwrap(),
|
|
on_last_window_closed: workspace.on_last_window_closed.unwrap(),
|
|
text_rendering_mode: workspace.text_rendering_mode.unwrap(),
|
|
resize_all_panels_in_dock: workspace
|
|
.resize_all_panels_in_dock
|
|
.clone()
|
|
.unwrap()
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect(),
|
|
close_on_file_delete: workspace.close_on_file_delete.unwrap(),
|
|
close_panel_on_toggle: workspace.close_panel_on_toggle.unwrap(),
|
|
use_system_window_tabs: workspace.use_system_window_tabs.unwrap(),
|
|
fullscreen_mode: workspace.fullscreen_mode.unwrap(),
|
|
zoomed_padding: workspace.zoomed_padding.unwrap(),
|
|
window_decorations: workspace.window_decorations.unwrap(),
|
|
focus_follows_mouse: FocusFollowsMouse {
|
|
enabled: workspace
|
|
.focus_follows_mouse
|
|
.unwrap()
|
|
.enabled
|
|
.unwrap_or(false),
|
|
debounce: Duration::from_millis(
|
|
workspace
|
|
.focus_follows_mouse
|
|
.unwrap()
|
|
.debounce_ms
|
|
.unwrap_or(250),
|
|
),
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Provides convenient access to whether "accessible mode" is enabled, mirroring
|
|
/// [`theme::ActiveTheme`] for the active theme. Import this trait to call
|
|
/// `cx.accessible_mode()`.
|
|
pub trait AccessibleMode {
|
|
/// Returns whether accessible mode is enabled.
|
|
fn accessible_mode(&self) -> bool;
|
|
}
|
|
|
|
impl AccessibleMode for App {
|
|
fn accessible_mode(&self) -> bool {
|
|
WorkspaceSettings::get_global(self).accessible_mode
|
|
}
|
|
}
|
|
|
|
/// Observes changes to the accessible-mode setting, invoking `callback` with the
|
|
/// new value whenever it changes. Mirrors the common
|
|
/// `cx.observe_global::<SettingsStore>` pattern, but only fires when the value
|
|
/// actually changes. The returned [`Subscription`] must be retained for the
|
|
/// callback to keep firing.
|
|
pub fn observe_accessible_mode(
|
|
cx: &mut App,
|
|
mut callback: impl FnMut(bool, &mut App) + 'static,
|
|
) -> Subscription {
|
|
let mut last = cx.accessible_mode();
|
|
cx.observe_global::<SettingsStore>(move |cx| {
|
|
let current = cx.accessible_mode();
|
|
if current != last {
|
|
last = current;
|
|
callback(current, cx);
|
|
}
|
|
})
|
|
}
|
|
|
|
impl Settings for TabBarSettings {
|
|
fn from_settings(content: &settings::SettingsContent) -> Self {
|
|
let tab_bar = content.tab_bar.clone().unwrap();
|
|
TabBarSettings {
|
|
show: tab_bar.show.unwrap(),
|
|
show_nav_history_buttons: tab_bar.show_nav_history_buttons.unwrap(),
|
|
show_tab_bar_buttons: tab_bar.show_tab_bar_buttons.unwrap(),
|
|
show_pinned_tabs_in_separate_row: tab_bar.show_pinned_tabs_in_separate_row.unwrap(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Deserialize, RegisterSetting)]
|
|
pub struct StatusBarSettings {
|
|
pub show: bool,
|
|
pub show_active_file: bool,
|
|
pub active_language_button: bool,
|
|
pub cursor_position_button: bool,
|
|
pub line_endings_button: bool,
|
|
pub active_encoding_button: EncodingDisplayOptions,
|
|
}
|
|
|
|
impl Settings for StatusBarSettings {
|
|
fn from_settings(content: &settings::SettingsContent) -> Self {
|
|
let status_bar = content.status_bar.clone().unwrap();
|
|
StatusBarSettings {
|
|
show: status_bar.show.unwrap(),
|
|
show_active_file: status_bar.show_active_file.unwrap(),
|
|
active_language_button: status_bar.active_language_button.unwrap(),
|
|
cursor_position_button: status_bar.cursor_position_button.unwrap(),
|
|
line_endings_button: status_bar.line_endings_button.unwrap(),
|
|
active_encoding_button: status_bar.active_encoding_button.unwrap(),
|
|
}
|
|
}
|
|
}
|