fix(cli): replace newlines with spaces in note body and preview text

Three sites were rendering multi-line text in single-line contexts:

1. `list notes` passed note bodies through `to_owned` which preserved
   embedded newlines, breaking table row alignment. Now uses
   `.replace('\n', " ")` to collapse to a single line.

2. `me` activity/inbox body previews were passed directly to
   `render::truncate()` with newlines intact, causing broken output
   when previews contained line breaks. Now normalizes to a `clean`
   variable before truncation.

Also corrects the `title_width` doc comment: flex_width is
terminal-aware with a floor, not clamped to [20, 80].

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
teernisse
2026-03-13 11:14:52 -04:00
parent 6c6389aaf6
commit 09c467a2d8
2 changed files with 6 additions and 4 deletions

View File

@@ -166,7 +166,7 @@ pub fn print_list_notes(result: &NoteListResult) {
let body = note
.body
.as_deref()
.map(std::borrow::ToOwned::to_owned)
.map(|b| b.replace('\n', " "))
.unwrap_or_default();
let path = format_note_path(note.position_new_path.as_deref(), note.position_new_line);
let parent = format_note_parent(note.noteable_type.as_deref(), note.parent_iid);

View File

@@ -8,7 +8,7 @@ use super::types::{
// ─── Layout Helpers ─────────────────────────────────────────────────────────
/// Compute the title/summary column width for a section given its fixed overhead.
/// Returns a width clamped to [20, 80].
/// Returns a terminal-aware width with a minimum of 20.
fn title_width(overhead: usize) -> usize {
render::flex_width(overhead, 20)
}
@@ -505,7 +505,8 @@ pub fn print_activity_section(events: &[MeActivityEvent], single_project: bool)
if let Some(preview) = &event.body_preview
&& !preview.is_empty()
{
let truncated = render::truncate(preview, render::flex_width(8, 30));
let clean = preview.replace('\n', " ");
let truncated = render::truncate(&clean, render::flex_width(8, 30));
println!(" {}", Theme::dim().render(&format!("\"{truncated}\"")));
}
}
@@ -606,7 +607,8 @@ pub fn print_since_last_check_section(since: &SinceLastCheck, single_project: bo
if let Some(preview) = &event.body_preview
&& !preview.is_empty()
{
let truncated = render::truncate(preview, render::flex_width(10, 30));
let clean = preview.replace('\n', " ");
let truncated = render::truncate(&clean, render::flex_width(10, 30));
println!(
" {}",
Theme::dim().render(&format!("\"{truncated}\""))