-
fix: properly wrap lines in the Rust TUI (#937)
发布于
2025-05-14 23:51:41 +00:00 As discussed on
https://github.com/openai/codex/commit/bb60494cd2abcc06d045ab3d5ee02b7e3505bb7a#commitcomment-156776835,
to properly support scrolling long content in Ratatui for a sequence of
cells, we need to:- take the
Vec<Line>for each cell - using the wrapping logic we want to use at render time, compute the
effective line count usingParagraph::line_count()(see
wrapped_line_count_for_cell()in this PR) - sum up the effective line count to compute the height of the area
being scrolled - given a
scroll_position: usize, index into the list of "effective
lines" and accumulate the appropriateVec<Line>for the cells that
should be displayed - take that
Vec<Line>to create aParagraphand use the same
line-wrapping policy that was used inwrapped_line_count_for_cell() - display the resulting
Paragraphand use the accounting to display a
scrollbar with the appropriate thumb size and offset without having to
render theVec<Line>for the full history
With this change, lines wrap as I expect and everything appears to
redraw correctly as I resize my terminal!下载附件
- take the