From 083cf2f511513effa688af8e063e91706d7b9231 Mon Sep 17 00:00:00 2001 From: Jeremy Rose Date: Tue, 7 Oct 2025 11:21:56 -0700 Subject: [PATCH] /diff mode wraps long lines --- codex-rs/tui/src/pager_overlay.rs | 20 +++++++++++++------ ...ests__static_overlay_wraps_long_lines.snap | 13 ++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 codex-rs/tui/src/snapshots/codex_tui__pager_overlay__tests__static_overlay_wraps_long_lines.snap diff --git a/codex-rs/tui/src/pager_overlay.rs b/codex-rs/tui/src/pager_overlay.rs index 7997625aae..2a40eaef51 100644 --- a/codex-rs/tui/src/pager_overlay.rs +++ b/codex-rs/tui/src/pager_overlay.rs @@ -474,12 +474,8 @@ pub(crate) struct StaticOverlay { impl StaticOverlay { pub(crate) fn with_title(lines: Vec>, title: String) -> Self { - Self::with_renderables( - vec![Box::new(CachedParagraph::new(Paragraph::new(Text::from( - lines, - ))))], - title, - ) + let paragraph = Paragraph::new(Text::from(lines)).wrap(Wrap { trim: false }); + Self::with_renderables(vec![Box::new(CachedParagraph::new(paragraph))], title) } pub(crate) fn with_renderables(renderables: Vec>, title: String) -> Self { @@ -790,6 +786,18 @@ mod tests { assert_snapshot!(term.backend()); } + #[test] + fn static_overlay_wraps_long_lines() { + let mut overlay = StaticOverlay::with_title( + vec!["a very long line that should wrap when rendered within a narrow pager overlay width".into()], + "S T A T I C".to_string(), + ); + let mut term = Terminal::new(TestBackend::new(24, 8)).expect("term"); + term.draw(|f| overlay.render(f.area(), f.buffer_mut())) + .expect("draw"); + assert_snapshot!(term.backend()); + } + #[test] fn pager_view_content_height_counts_renderables() { let pv = PagerView::new( diff --git a/codex-rs/tui/src/snapshots/codex_tui__pager_overlay__tests__static_overlay_wraps_long_lines.snap b/codex-rs/tui/src/snapshots/codex_tui__pager_overlay__tests__static_overlay_wraps_long_lines.snap new file mode 100644 index 0000000000..2dfab2aa7d --- /dev/null +++ b/codex-rs/tui/src/snapshots/codex_tui__pager_overlay__tests__static_overlay_wraps_long_lines.snap @@ -0,0 +1,13 @@ +--- +source: tui/src/pager_overlay.rs +assertion_line: 798 +expression: term.backend() +--- +"/ S T A T I C / / / / / " +"a very long line that " +"should wrap when " +"rendered within a narrow" +"─────────────────── 0% ─" +" ↑/↓ to scroll pgup/pg" +" q to quit " +" "