feat(show): Display full discussion content without truncation
Remove artificial length limits from `lore show` output to display complete descriptions and discussion threads. Previously, descriptions were truncated to 500 characters and discussion notes to 300 characters, which cut off important context when reviewing issues and MRs. Users often need the full content to understand the complete discussion history. Changes: - Remove truncate() helper function and its 2 unit tests - Pass description and note bodies directly to wrap_text() - Affects both print_show_issue() and print_show_mr() The wrap_text() function continues to handle line wrapping for readability at the configured widths (76/72/68 chars depending on nesting level). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -556,15 +556,6 @@ fn format_date(ms: i64) -> String {
|
||||
iso.split('T').next().unwrap_or(&iso).to_string()
|
||||
}
|
||||
|
||||
fn truncate(s: &str, max_len: usize) -> String {
|
||||
if s.chars().count() <= max_len {
|
||||
s.to_string()
|
||||
} else {
|
||||
let truncated: String = s.chars().take(max_len.saturating_sub(3)).collect();
|
||||
format!("{truncated}...")
|
||||
}
|
||||
}
|
||||
|
||||
fn wrap_text(text: &str, width: usize, indent: &str) -> String {
|
||||
let mut result = String::new();
|
||||
let mut current_line = String::new();
|
||||
@@ -671,8 +662,7 @@ pub fn print_show_issue(issue: &IssueDetail) {
|
||||
|
||||
println!("{}", style("Description:").bold());
|
||||
if let Some(desc) = &issue.description {
|
||||
let truncated = truncate(desc, 500);
|
||||
let wrapped = wrap_text(&truncated, 76, " ");
|
||||
let wrapped = wrap_text(desc, 76, " ");
|
||||
println!(" {}", wrapped);
|
||||
} else {
|
||||
println!(" {}", style("(no description)").dim());
|
||||
@@ -705,7 +695,7 @@ pub fn print_show_issue(issue: &IssueDetail) {
|
||||
style(format!("@{}", first_note.author_username)).cyan(),
|
||||
format_date(first_note.created_at)
|
||||
);
|
||||
let wrapped = wrap_text(&truncate(&first_note.body, 300), 72, " ");
|
||||
let wrapped = wrap_text(&first_note.body, 72, " ");
|
||||
println!(" {}", wrapped);
|
||||
println!();
|
||||
|
||||
@@ -715,7 +705,7 @@ pub fn print_show_issue(issue: &IssueDetail) {
|
||||
style(format!("@{}", reply.author_username)).cyan(),
|
||||
format_date(reply.created_at)
|
||||
);
|
||||
let wrapped = wrap_text(&truncate(&reply.body, 300), 68, " ");
|
||||
let wrapped = wrap_text(&reply.body, 68, " ");
|
||||
println!(" {}", wrapped);
|
||||
println!();
|
||||
}
|
||||
@@ -796,8 +786,7 @@ pub fn print_show_mr(mr: &MrDetail) {
|
||||
|
||||
println!("{}", style("Description:").bold());
|
||||
if let Some(desc) = &mr.description {
|
||||
let truncated = truncate(desc, 500);
|
||||
let wrapped = wrap_text(&truncated, 76, " ");
|
||||
let wrapped = wrap_text(desc, 76, " ");
|
||||
println!(" {}", wrapped);
|
||||
} else {
|
||||
println!(" {}", style("(no description)").dim());
|
||||
@@ -834,7 +823,7 @@ pub fn print_show_mr(mr: &MrDetail) {
|
||||
style(format!("@{}", first_note.author_username)).cyan(),
|
||||
format_date(first_note.created_at)
|
||||
);
|
||||
let wrapped = wrap_text(&truncate(&first_note.body, 300), 72, " ");
|
||||
let wrapped = wrap_text(&first_note.body, 72, " ");
|
||||
println!(" {}", wrapped);
|
||||
println!();
|
||||
|
||||
@@ -844,7 +833,7 @@ pub fn print_show_mr(mr: &MrDetail) {
|
||||
style(format!("@{}", reply.author_username)).cyan(),
|
||||
format_date(reply.created_at)
|
||||
);
|
||||
let wrapped = wrap_text(&truncate(&reply.body, 300), 68, " ");
|
||||
let wrapped = wrap_text(&reply.body, 68, " ");
|
||||
println!(" {}", wrapped);
|
||||
println!();
|
||||
}
|
||||
@@ -1234,16 +1223,6 @@ mod tests {
|
||||
assert_eq!(result[1].iid, 8);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate_leaves_short_strings() {
|
||||
assert_eq!(truncate("short", 10), "short");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn truncate_adds_ellipsis() {
|
||||
assert_eq!(truncate("this is a long string", 10), "this is...");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wrap_text_single_line() {
|
||||
assert_eq!(wrap_text("hello world", 80, " "), "hello world");
|
||||
|
||||
Reference in New Issue
Block a user