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",
"style": {
"editor.foreground": "#DDDDDD",
"editor.background": "#131313",
"editor.active_line.background": "#272727",
"editor.background": "#000000",
"editor.active_line.background": "#131313",
"editor.line_number": "#8F8F8F",
"editor.active_line_number": "#DDDDDD",
"conflict": "#D2602D",

View file

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

View file

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

View file

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