Make unnecessary code fade configurable (#14442)
This PR allows configuring the intensity of code fade applied to unused code (relates to #4785). _Note: Right now I included it as a top level config which might be a little out of place (but is easiest to instrument). Open for suggestions on where else it would be better suited for._ _Note 2: I am unfamiliar with the codebase. Feel free to either close this PR and re-implement in a better way or suggest high level changes if I'm approaching anything wrong :)._ Release Notes: - Added `unnecesary_code_fade` setting to control how strongly to fade unused code. --------- Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
co-authored by
Marshall Bowers
parent
ebcc2945c5
commit
5c0d800b21
@@ -74,8 +74,6 @@ pub enum FoldStatus {
|
||||
|
||||
pub type RenderFoldToggle = Arc<dyn Fn(FoldStatus, &mut WindowContext) -> 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 {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user