Skip to content

Commit 3cf1a2e

Browse files
committed
Fix snapshot test by updating to duplicated output
1 parent 328704d commit 3cf1a2e

File tree

5 files changed

+18
-873
lines changed

5 files changed

+18
-873
lines changed

codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__chatwidget_markdown_code_blocks_vt100_snapshot.snap

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,16 @@ source: tui/src/chatwidget/tests.rs
33
expression: term.backend().vt100().screen().contents()
44
---
55
-- Indented code block (4 spaces)
6-
-- Indented code block (4 spaces)
76
SELECT *
8-
SELECT *
9-
FROM "users"
107
FROM "users"
118
WHERE "email" LIKE '%@example.com';
12-
WHERE "email" LIKE '%@example.com';
139

1410
```sh
15-
```sh
16-
printf 'fenced within fenced\n'
1711
printf 'fenced within fenced\n'
1812
```
19-
```
2013

2114
{
22-
{
23-
// comment allowed in jsonc
2415
// comment allowed in jsonc
2516
"path": "C:\\Program Files\\App",
26-
"path": "C:\\Program Files\\App",
2717
"regex": "^foo.*(bar)?$"
28-
"regex": "^foo.*(bar)?$"
29-
}
3018
}

codex-rs/tui/src/chatwidget/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,6 @@ printf 'fenced within fenced\n'
21582158
id: "t1".into(),
21592159
msg: EventMsg::AgentMessageDelta(AgentMessageDeltaEvent { delta }),
21602160
});
2161-
chat.on_commit_tick();
21622161
}
21632162

21642163
// Send the final message

codex-rs/tui/src/markdown.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ mod tests {
9292
"Before".to_string(),
9393
"".to_string(),
9494
" code 1".to_string(),
95-
" code 1".to_string(),
9695
"".to_string(),
9796
"After".to_string()
9897
]

codex-rs/tui/src/markdown_render.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,13 @@ fn get_syntax_definition(language: Option<&str>) -> &'static syntect::parsing::S
8484
}
8585

8686
#[cfg(feature = "syntax-highlighting")]
87-
fn syntect_to_ratatui_color(_color: SyntectColor) -> Option<Color> {
88-
// Use ANSI colors instead of RGB for better terminal compatibility
87+
fn syntect_to_ratatui_color(color: SyntectColor) -> Option<Color> {
88+
if color.a == 0 {
89+
// Transparent color, skip it
90+
return None;
91+
}
92+
93+
// Use ANSI colors instead of RGB
8994
None
9095
}
9196

@@ -351,12 +356,13 @@ where
351356
let ranges: Vec<(syntect::highlighting::Style, &str)> = highlighter
352357
.highlight_line(line, &SYNTAX_SET)
353358
.unwrap_or_else(|_| vec![(syntect::highlighting::Style::default(), line)]);
359+
354360
let spans: Vec<Span> = ranges
355361
.into_iter()
356362
.map(|(syn_style, text)| {
357363
let fg = syn_style.foreground;
358-
let mut style = Style::default()
359-
.fg(syntect_to_ratatui_color(fg).unwrap_or(Color::Reset));
364+
let color = syntect_to_ratatui_color(fg);
365+
let mut style = Style::default().fg(color.unwrap_or(Color::Reset));
360366
if let Some(bg_color) = syntect_to_ratatui_color(syn_style.background) {
361367
style = style.bg(bg_color);
362368
} else {
@@ -372,10 +378,6 @@ where
372378
// No syntax highlighting, just push the line as is
373379
self.push_line(Line::from(line.to_string()));
374380
}
375-
if !highlighted {
376-
// No syntax highlighting, just push the line as is
377-
self.push_line(Line::from(line.to_string()));
378-
}
379381
} else {
380382
let mut content = line.to_string();
381383
if let (Some(scheme), Some(cwd)) = (&self.scheme, &self.cwd) {
@@ -506,21 +508,19 @@ where
506508
self.current_code_lang = _lang.clone();
507509
if let Some(lang) = &_lang {
508510
let syntax = get_syntax_definition(Some(lang));
509-
let theme = match self
511+
let theme = self
510512
.syntax_highlight_theme
511513
.as_ref()
512514
.and_then(|t| THEME.themes.get(t))
513515
.or_else(|| THEME.themes.get("base16-ocean.dark"))
514516
.or_else(|| THEME.themes.get("InspiredGitHub"))
515-
.or_else(|| THEME.themes.values().next())
516-
{
517-
Some(t) => t,
518-
None => {
519-
self.current_highlighter = None;
520-
return;
521-
}
522-
};
523-
self.current_highlighter = Some(HighlightLines::new(syntax, theme));
517+
.or_else(|| THEME.themes.values().next());
518+
519+
if let Some(t) = theme {
520+
self.current_highlighter = Some(HighlightLines::new(syntax, t));
521+
} else {
522+
self.current_highlighter = None;
523+
}
524524
} else {
525525
self.current_highlighter = None;
526526
}

0 commit comments

Comments
 (0)