Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion codex-rs/tui/src/history_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ impl HistoryCell for UserHistoryCell {
.lines()
.map(|l| Line::from(l).style(style))
.collect::<Vec<_>>(),
RtOptions::new(wrap_width as usize),
// Wrap algorithm matches textarea.rs.
RtOptions::new(wrap_width as usize).wrap_algorithm(textwrap::WrapAlgorithm::FirstFit),
);

lines.push(Line::from("").style(style));
Expand Down
7 changes: 6 additions & 1 deletion codex-rs/tui/src/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use ratatui::text::Line;
use ratatui::text::Span;
use std::ops::Range;
use textwrap::Options;
use textwrap::wrap_algorithms::Penalties;

use crate::render::line_utils::push_owned_lines;

Expand Down Expand Up @@ -90,7 +91,11 @@ impl<'a> RtOptions<'a> {
subsequent_indent: Line::default(),
break_words: true,
word_separator: textwrap::WordSeparator::new(),
wrap_algorithm: textwrap::WrapAlgorithm::new(),
wrap_algorithm: textwrap::WrapAlgorithm::OptimalFit(Penalties {
// ~infinite overflow penalty, we never want to overflow a line.
overflow_penalty: usize::MAX / 4,
..Default::default()
}),
word_splitter: textwrap::WordSplitter::HyphenSplitter,
}
}
Expand Down
Loading