Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Remove the redundant borrowed line wrapping helper (#33870)

jiff57467275cb0
diff --git a/codex-rs/tui/src/wrapping.rs b/codex-rs/tui/src/wrapping.rs
index bc66b18ad5..fcec7c1ae7 100644
--- a/codex-rs/tui/src/wrapping.rs
+++ b/codex-rs/tui/src/wrapping.rs
@@ -1007,29 +1007,6 @@ where
out
}
-#[allow(dead_code)]
-pub(crate) fn word_wrap_lines_borrowed<'a, I, O>(lines: I, width_or_options: O) -> Vec<Line<'a>>
-where
- I: IntoIterator<Item = &'a Line<'a>>,
- O: Into<RtOptions<'a>>,
-{
- let base_opts: RtOptions<'a> = width_or_options.into();
- let mut out: Vec<Line<'a>> = Vec::new();
- let mut first = true;
- for line in lines.into_iter() {
- let opts = if first {
- base_opts.clone()
- } else {
- base_opts
- .clone()
- .initial_indent(base_opts.subsequent_indent.clone())
- };
- out.extend(word_wrap_line(line, opts));
- first = false;
- }
- out
-}
-
fn slice_line_spans<'a>(
original: &'a Line<'a>,
span_bounds: &[(Range<usize>, ratatui::style::Style)],
@@ -1253,30 +1230,6 @@ mod tests {
assert_eq!(rendered, vec!["hello", "world!"]);
}
- #[test]
- fn wrap_lines_borrowed_applies_initial_indent_only_once() {
- let opts = RtOptions::new(/*width*/ 8)
- .initial_indent(Line::from("- "))
- .subsequent_indent(Line::from(" "));
-
- let lines = [Line::from("hello world"), Line::from("foo bar baz")];
- let out = word_wrap_lines_borrowed(lines.iter(), opts);
-
- let rendered: Vec<String> = out.iter().map(concat_line).collect();
- assert!(rendered.first().unwrap().starts_with("- "));
- for r in rendered.iter().skip(1) {
- assert!(r.starts_with(" "));
- }
- }
-
- #[test]
- fn wrap_lines_borrowed_without_indents_is_concat_of_single_wraps() {
- let lines = [Line::from("hello"), Line::from("world!")];
- let out = word_wrap_lines_borrowed(lines.iter(), /*width_or_options*/ 10);
- let rendered: Vec<String> = out.iter().map(concat_line).collect();
- assert_eq!(rendered, vec!["hello", "world!"]);
- }
-
#[test]
fn wrap_lines_accepts_borrowed_iterators() {
let lines = [Line::from("hello world"), Line::from("foo bar baz")];
@@ -1307,7 +1260,7 @@ mod tests {
let line = Line::from(sample);
let lines = [line];
// Force small width to exercise wrapping at spaces.
- let wrapped = word_wrap_lines_borrowed(&lines, /*width_or_options*/ 40);
+ let wrapped = word_wrap_lines(&lines, /*width_or_options*/ 40);
let joined: String = wrapped.iter().map(ToString::to_string).join("\n");
assert_eq!(
joined,