diff --git a/codex-rs/tui/src/markdown_render.rs b/codex-rs/tui/src/markdown_render.rs index 7c68835656..1fcd694534 100644 --- a/codex-rs/tui/src/markdown_render.rs +++ b/codex-rs/tui/src/markdown_render.rs @@ -1052,6 +1052,14 @@ impl<'a, 'policy> Writer<'a, 'policy> { self.needs_newline = false; } + /// Begin an inline run at the list marker or after the preceding block. + fn start_pending_inline_line(&mut self) { + if (self.pending_marker_line || self.needs_newline) && !self.in_table_cell() { + self.push_line(Line::default()); + self.needs_newline = false; + } + } + fn code(&mut self, code: CowStr<'a>) { if self.buffer_link_label(&code) { self.push_local_link_label_span(Span::from(code.into_string()).style(self.styles.code)); @@ -1063,10 +1071,7 @@ impl<'a, 'policy> Writer<'a, 'policy> { return; } - if self.pending_marker_line { - self.push_line(Line::default()); - self.pending_marker_line = false; - } + self.start_pending_inline_line(); let span = Span::from(code.into_string()).style(self.styles.code); self.push_span(span); } @@ -2385,10 +2390,7 @@ impl<'a, 'policy> Writer<'a, 'policy> { } fn push_link(&mut self, dest_url: String, source: usize) { - if (self.pending_marker_line || self.needs_newline) && !self.in_table_cell() { - self.push_line(Line::default()); - self.needs_newline = false; - } + self.start_pending_inline_line(); let style_label = (self.is_hidden_link_destination)(&dest_url); if style_label { self.push_inline_style(self.styles.link); diff --git a/codex-rs/tui/src/markdown_render_tests.rs b/codex-rs/tui/src/markdown_render_tests.rs index 5fa0a32ee5..840eb5ea5e 100644 --- a/codex-rs/tui/src/markdown_render_tests.rs +++ b/codex-rs/tui/src/markdown_render_tests.rs @@ -1060,6 +1060,10 @@ second](guide.md) [Map](guide.md#L2-L4) details - # Explicit [`Map`](./guide.md#L2-L4) details +- # Inline + `Map` details +- # Plain + Map details - # Source [source.rs:2-4](source.rs:2-4) notes diff --git a/codex-rs/tui/src/snapshots/codex_tui__markdown_render__markdown_render_tests__file_link_preserves_path_labels_and_formats_destinations.snap b/codex-rs/tui/src/snapshots/codex_tui__markdown_render__markdown_render_tests__file_link_preserves_path_labels_and_formats_destinations.snap index fe76f11fac..b3cbdebe35 100644 --- a/codex-rs/tui/src/snapshots/codex_tui__markdown_render__markdown_render_tests__file_link_preserves_path_labels_and_formats_destinations.snap +++ b/codex-rs/tui/src/snapshots/codex_tui__markdown_render__markdown_render_tests__file_link_preserves_path_labels_and_formats_destinations.snap @@ -35,6 +35,12 @@ second (guide.md) • # Explicit Map (./guide.md:2-4) details +• # Inline + Map details + +• # Plain + Map details + • # Source source.rs:2-4 notes diff --git a/codex-rs/tui/src/transcript_view/markdown_copy_tests.rs b/codex-rs/tui/src/transcript_view/markdown_copy_tests.rs index 90ff01fa77..c9c11611a5 100644 --- a/codex-rs/tui/src/transcript_view/markdown_copy_tests.rs +++ b/codex-rs/tui/src/transcript_view/markdown_copy_tests.rs @@ -136,6 +136,7 @@ fn inline_code_selection_copies_only_selected_content() { for (source, selected) in [ ("before `something` after", "something"), ("before `something` after", "some"), + ("- # Reading\n `gauge` value", "aug"), ("before `something` after", "thing"), ("before `closeRequested_` after", "Requested"), ("before ``a`b`` after", "a`"), @@ -259,7 +260,7 @@ fn inline_boundaries_preserve_selected_text_and_formatting() { #[test] fn lists_keep_nesting_and_paragraphs_without_sibling_spacers() { - let source = "3. first item long enough to wrap\n4. second item\n - nested `code`\n\n another paragraph\n - next nested\n5. final item\n\nOutside."; + let source = "3. first item long enough to wrap\n4. second item\n - nested `code`\n\n another paragraph\n - next nested\n5. final item\n\nOutside.\n\n- # Reading\n `gauge` value"; let mut copies = Vec::new(); for width in [24, 80] { let layout = markdown_layout(source, width); diff --git a/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__inline_code_selection_copies_only_selected_content.snap b/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__inline_code_selection_copies_only_selected_content.snap index b0f369a4a2..6d0c53fac9 100644 --- a/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__inline_code_selection_copies_only_selected_content.snap +++ b/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__inline_code_selection_copies_only_selected_content.snap @@ -6,6 +6,9 @@ before `something` after Selected "something" → ("something", PlainText) before `something` after Selected "some" → ("some", PlainText) +- # Reading + `gauge` value +Selected "aug" → ("aug", PlainText) before `something` after Selected "thing" → ("thing", PlainText) before `closeRequested_` after diff --git a/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__lists_keep_nesting_and_paragraphs_without_sibling_spacers.snap b/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__lists_keep_nesting_and_paragraphs_without_sibling_spacers.snap index 1ff3493aaf..b458e4c818 100644 --- a/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__lists_keep_nesting_and_paragraphs_without_sibling_spacers.snap +++ b/codex-rs/tui/src/transcript_view/snapshots/codex_tui__transcript_view__markdown_copy_tests__lists_keep_nesting_and_paragraphs_without_sibling_spacers.snap @@ -1,6 +1,5 @@ --- source: tui/src/transcript_view/markdown_copy_tests.rs -assertion_line: 76 expression: "copies[0]" --- 3. first item long enough to wrap @@ -12,3 +11,6 @@ expression: "copies[0]" 5. final item Outside. + +- # Reading + `gauge` value