diff --git a/assets/settings/default.json b/assets/settings/default.json index cf521a7136724d892fe7dc829c195bb2ecc4def3..c232d0ba68d7f5d9606876e7af60fc726154fd05 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -64,6 +64,8 @@ "ui_font_weight": 400, // The default font size for text in the UI "ui_font_size": 16, + // How much to fade out unused code. + "unnecessary_code_fade": 0.3, // The factor to grow the active pane by. Defaults to 1.0 // which gives the same size as all other panes. "active_pane_magnification": 1.0, diff --git a/crates/assistant/src/prompt_library.rs b/crates/assistant/src/prompt_library.rs index ff9af6b7e88abc580ac468f775f2f1dc9a0ff677..c8bafdf7fad44ece823f15f83fd622d7ecc0aa37 100644 --- a/crates/assistant/src/prompt_library.rs +++ b/crates/assistant/src/prompt_library.rs @@ -926,6 +926,7 @@ impl PromptLibrary { color: Some(cx.theme().status().predictive), ..HighlightStyle::default() }, + ..EditorStyle::default() }, )), ), diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index 0e08a9eae7dedbb3f8d3d3928b4f0a6114fc3472..ef69c08546bcf948cb545fae5971d96445ebe67f 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -74,8 +74,6 @@ pub enum FoldStatus { pub type RenderFoldToggle = Arc AnyElement>; -const UNNECESSARY_CODE_FADE: f32 = 0.3; - pub trait ToDisplayPoint { fn to_display_point(&self, map: &DisplaySnapshot) -> DisplayPoint; } @@ -691,7 +689,7 @@ impl DisplaySnapshot { let mut diagnostic_highlight = HighlightStyle::default(); if chunk.is_unnecessary { - diagnostic_highlight.fade_out = Some(UNNECESSARY_CODE_FADE); + diagnostic_highlight.fade_out = Some(editor_style.unnecessary_code_fade); } if let Some(severity) = chunk.diagnostic_severity { diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 6cbdb0daaa13ca4667a4dd687608f4fc989b31e5..b2314c70e8f50948e1f41e47c672bd021c561ce3 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -384,6 +384,7 @@ pub struct EditorStyle { pub status: StatusColors, pub inlay_hints_style: HighlightStyle, pub suggestions_style: HighlightStyle, + pub unnecessary_code_fade: f32, } impl Default for EditorStyle { @@ -400,6 +401,7 @@ impl Default for EditorStyle { status: StatusColors::dark(), inlay_hints_style: HighlightStyle::default(), suggestions_style: HighlightStyle::default(), + unnecessary_code_fade: Default::default(), } } } @@ -9698,6 +9700,7 @@ impl Editor { color: Some(cx.theme().status().predictive), ..HighlightStyle::default() }, + ..EditorStyle::default() }, )) .into_any_element() @@ -12588,6 +12591,7 @@ impl Render for Editor { color: Some(cx.theme().status().predictive), ..HighlightStyle::default() }, + unnecessary_code_fade: ThemeSettings::get_global(cx).unnecessary_code_fade, }, ) } diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rs index 487f8e973c29ad6011577cce536a67debcbb4eb6..60f4768f06c1f17bbb4390665f4d416ae30eff1f 100644 --- a/crates/theme/src/settings.rs +++ b/crates/theme/src/settings.rs @@ -91,6 +91,7 @@ pub struct ThemeSettings { pub active_theme: Arc, pub theme_overrides: Option, pub ui_density: UiDensity, + pub unnecessary_code_fade: f32, } impl ThemeSettings { @@ -283,6 +284,10 @@ pub struct ThemeSettingsContent { #[serde(rename = "unstable.ui_density", default)] pub ui_density: Option, + /// How much to fade out unused code. + #[serde(default)] + pub unnecessary_code_fade: Option, + /// EXPERIMENTAL: Overrides for the current theme. /// /// These values will override the ones on the current theme specified in `theme`. @@ -550,6 +555,7 @@ impl settings::Settings for ThemeSettings { .unwrap(), theme_overrides: None, ui_density: defaults.ui_density.unwrap_or(UiDensity::Default), + unnecessary_code_fade: defaults.unnecessary_code_fade.unwrap_or(0.0), }; for value in sources.user.into_iter().chain(sources.release_channel) { @@ -602,6 +608,10 @@ impl settings::Settings for ThemeSettings { value.buffer_font_size.map(Into::into), ); merge(&mut this.buffer_line_height, value.buffer_line_height); + + // Clamp the `unnecessary_code_fade` to ensure text can't disappear entirely. + merge(&mut this.unnecessary_code_fade, value.unnecessary_code_fade); + this.unnecessary_code_fade = this.unnecessary_code_fade.clamp(0.0, 0.9); } Ok(this) diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 048f81dccf0eed5dbeb1dde4c4c87930ee881171..0a20664325d09e7d5662440206cf023a7a1409af 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -1902,6 +1902,27 @@ Run the `theme selector: toggle` action in the command palette to see a current }, ``` +## Unnecessary Code Fade + +- Description: How much to fade out unused code. +- Setting: `unnecessary_code_fade` +- Default: `0.3` + +**Options** + +Float values between `0.0` and `0.9`, where: + +- `0.0` means no fading (unused code looks the same as used code) +- `0.9` means maximum fading (unused code is very faint but still visible) + +**Example** + +```json +{ + "unnecessary_code_fade": 0.5 +} +``` + ## An example configuration: ```json