editor: rename code/diff view features and modules

This commit is contained in:
2026-11-11 09:11:23 +07:00
parent 6d6861a766
commit 63ed15c9cb
10 changed files with 34 additions and 34 deletions
+14 -14
View File
@@ -1,24 +1,24 @@
//! Shared helpers for the editor's views: gutter cells, role colors and run
//! styles, code line text, language mapping and change washes.
#[cfg(any(feature = "code_view", feature = "markdown_view"))]
#[cfg(any(feature = "code", feature = "markdown"))]
use std::ops::Range;
#[cfg(feature = "markdown_view")]
#[cfg(feature = "markdown")]
use crate::highlight::{Language, Line};
#[cfg(feature = "markdown_view")]
#[cfg(feature = "markdown")]
use gpui::StyledText;
#[cfg(any(feature = "code_view", feature = "markdown_view"))]
#[cfg(any(feature = "code", feature = "markdown"))]
use gpui::{App, HighlightStyle, Hsla, IntoElement, ParentElement as _, Styled as _, div};
#[cfg(any(feature = "code_view", feature = "markdown_view"))]
#[cfg(any(feature = "code", feature = "markdown"))]
use gpui_native_theme::{ActiveTheme as _, ColorTokens, Ramps};
#[cfg(feature = "diff_view")]
#[cfg(feature = "diff")]
use gpui_native_theme::{WASH_ALPHA, WASH_ALPHA_GUTTER, WASH_ALPHA_STRONG};
#[cfg(any(feature = "code_view", feature = "markdown_view"))]
#[cfg(any(feature = "code", feature = "markdown"))]
use crate::highlight::Role;
#[cfg(any(feature = "code_view", feature = "markdown_view"))]
#[cfg(any(feature = "code", feature = "markdown"))]
impl Role {
/// Maps the role to the theme's semantic palette.
pub(crate) fn color(self, colors: ColorTokens, ramps: Ramps) -> Hsla {
@@ -50,7 +50,7 @@ impl Role {
}
}
#[cfg(feature = "markdown_view")]
#[cfg(feature = "markdown")]
impl Language {
/// Maps a fence info string to a bundled grammar.
pub(crate) fn from_fence_info(info: &str) -> Option<Language> {
@@ -65,7 +65,7 @@ impl Language {
}
/// A gutter cell sized to the whole row.
#[cfg(feature = "code_view")]
#[cfg(feature = "code")]
pub(crate) fn gutter_cell<E>(cx: &App, color: Hsla, content: E) -> gpui::Div
where
E: IntoElement,
@@ -86,7 +86,7 @@ where
}
/// A change wash: the ramp color at the alpha rows tint with.
#[cfg(feature = "diff_view")]
#[cfg(feature = "diff")]
pub(crate) fn wash(color: Hsla) -> Hsla {
Hsla {
a: color.a * WASH_ALPHA,
@@ -95,7 +95,7 @@ pub(crate) fn wash(color: Hsla) -> Hsla {
}
/// The stronger wash under number gutters and intra-line word changes.
#[cfg(feature = "diff_view")]
#[cfg(feature = "diff")]
pub(crate) fn wash_strong(color: Hsla) -> Hsla {
Hsla {
a: color.a * WASH_ALPHA_STRONG,
@@ -104,7 +104,7 @@ pub(crate) fn wash_strong(color: Hsla) -> Hsla {
}
/// The subtle wash that sets the number gutter off from the code.
#[cfg(feature = "diff_view")]
#[cfg(feature = "diff")]
pub(crate) fn wash_gutter(colors: &ColorTokens) -> Hsla {
Hsla {
a: colors.muted.a * WASH_ALPHA_GUTTER,
@@ -113,7 +113,7 @@ pub(crate) fn wash_gutter(colors: &ColorTokens) -> Hsla {
}
/// One highlighted code line as styled text, roles resolved from the theme.
#[cfg(feature = "markdown_view")]
#[cfg(feature = "markdown")]
pub(crate) fn code_line(line: &Line, colors: ColorTokens, ramps: Ramps) -> StyledText {
let mut highlights: Vec<(Range<usize>, HighlightStyle)> = Vec::new();
let mut offset = 0usize;