text_view: Fix code block background to use accent color. (#1014)

This commit is contained in:
Jason Lee 2025-06-26 18:30:34 +08:00 committed by GitHub
parent 819161ec58
commit babb04fcaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 12 deletions

View file

@ -3,8 +3,8 @@
"appearance": "dark", "appearance": "dark",
"style": { "style": {
"editor.foreground": "#DDDDDD", "editor.foreground": "#DDDDDD",
"editor.background": "#131313", "editor.background": "#000000",
"editor.active_line.background": "#272727", "editor.active_line.background": "#131313",
"editor.line_number": "#8F8F8F", "editor.line_number": "#8F8F8F",
"editor.active_line_number": "#DDDDDD", "editor.active_line_number": "#DDDDDD",
"conflict": "#D2602D", "conflict": "#D2602D",

View file

@ -4,7 +4,7 @@
"style": { "style": {
"editor.foreground": "#000000", "editor.foreground": "#000000",
"editor.background": "#ffffff", "editor.background": "#ffffff",
"editor.active_line.background": "#F0F0F0", "editor.active_line.background": "#F5F5F5",
"editor.line_number": "#929292", "editor.line_number": "#929292",
"editor.active_line_number": "#000000", "editor.active_line_number": "#000000",
"conflict": "#C5060B", "conflict": "#C5060B",
@ -172,4 +172,4 @@
} }
} }
} }
} }

View file

@ -581,6 +581,7 @@ impl Node {
fn render_codeblock( fn render_codeblock(
code_block: CodeBlock, code_block: CodeBlock,
mb: Rems, mb: Rems,
_: &TextViewStyle,
_: &mut Window, _: &mut Window,
cx: &mut App, cx: &mut App,
) -> AnyElement { ) -> AnyElement {
@ -588,7 +589,7 @@ impl Node {
.mb(mb) .mb(mb)
.p_3() .p_3()
.rounded(cx.theme().radius) .rounded(cx.theme().radius)
.bg(cx.theme().secondary) .bg(cx.theme().accent)
.font_family("Menlo, Monaco, Consolas, monospace") .font_family("Menlo, Monaco, Consolas, monospace")
.text_size(rems(0.875)) .text_size(rems(0.875))
.relative() .relative()
@ -600,7 +601,7 @@ impl Node {
self, self,
list_state: Option<ListState>, list_state: Option<ListState>,
is_last_child: bool, is_last_child: bool,
text_view_style: &TextViewStyle, style: &TextViewStyle,
window: &mut Window, window: &mut Window,
cx: &mut App, cx: &mut App,
) -> impl IntoElement { ) -> impl IntoElement {
@ -608,7 +609,7 @@ impl Node {
let mb = if in_list || is_last_child { let mb = if in_list || is_last_child {
rems(0.) rems(0.)
} else { } else {
text_view_style.paragraph_gap style.paragraph_gap
}; };
match self { match self {
@ -617,7 +618,7 @@ impl Node {
let children_len = children.len(); let children_len = children.len();
children.into_iter().enumerate().map(move |(index, c)| { children.into_iter().enumerate().map(move |(index, c)| {
let is_last_child = index == children_len - 1; let is_last_child = index == children_len - 1;
c.render(None, is_last_child, text_view_style, window, cx) c.render(None, is_last_child, style, window, cx)
}) })
}) })
.into_any_element(), .into_any_element(),
@ -633,7 +634,7 @@ impl Node {
_ => (rems(1.), FontWeight::NORMAL), _ => (rems(1.), FontWeight::NORMAL),
}; };
let text_size = text_size.to_pixels(text_view_style.heading_base_font_size); let text_size = text_size.to_pixels(style.heading_base_font_size);
h_flex() h_flex()
.mb(rems(0.3)) .mb(rems(0.3))
@ -669,7 +670,7 @@ impl Node {
todo: list_state.todo, todo: list_state.todo,
depth: list_state.depth, depth: list_state.depth,
}, },
text_view_style, style,
window, window,
cx, cx,
)); ));
@ -681,7 +682,9 @@ impl Node {
items items
}) })
.into_any_element(), .into_any_element(),
Node::CodeBlock(code_block) => Self::render_codeblock(code_block, mb, window, cx), Node::CodeBlock(code_block) => {
Self::render_codeblock(code_block, mb, style, window, cx)
}
Node::Table { .. } => Self::render_table(&self, window, cx).into_any_element(), Node::Table { .. } => Self::render_table(&self, window, cx).into_any_element(),
Node::Divider => div() Node::Divider => div()
.bg(cx.theme().border) .bg(cx.theme().border)

View file

@ -355,7 +355,7 @@ impl ThemeColor {
pub fn dark() -> Self { pub fn dark() -> Self {
Self { Self {
accent: neutral_800(), accent: neutral_900(),
accent_foreground: neutral_50(), accent_foreground: neutral_50(),
accordion: neutral_950(), accordion: neutral_950(),
accordion_active: neutral_800(), accordion_active: neutral_800(),