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:
@@ -166,7 +166,7 @@ pub fn print_list_notes(result: &NoteListResult) {
|
|||||||
let body = note
|
let body = note
|
||||||
.body
|
.body
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.map(std::borrow::ToOwned::to_owned)
|
.map(|b| b.replace('\n', " "))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let path = format_note_path(note.position_new_path.as_deref(), note.position_new_line);
|
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);
|
let parent = format_note_parent(note.noteable_type.as_deref(), note.parent_iid);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use super::types::{
|
|||||||
// ─── Layout Helpers ─────────────────────────────────────────────────────────
|
// ─── Layout Helpers ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// Compute the title/summary column width for a section given its fixed overhead.
|
/// 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 {
|
fn title_width(overhead: usize) -> usize {
|
||||||
render::flex_width(overhead, 20)
|
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
|
if let Some(preview) = &event.body_preview
|
||||||
&& !preview.is_empty()
|
&& !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}\"")));
|
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
|
if let Some(preview) = &event.body_preview
|
||||||
&& !preview.is_empty()
|
&& !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!(
|
println!(
|
||||||
" {}",
|
" {}",
|
||||||
Theme::dim().render(&format!("\"{truncated}\""))
|
Theme::dim().render(&format!("\"{truncated}\""))
|
||||||
|
|||||||
Reference in New Issue
Block a user