From e62c6ce03f844ec2f586b7561532315842a8a82c Mon Sep 17 00:00:00 2001 From: polamin Date: Sat, 21 Feb 2026 04:10:12 +0700 Subject: [PATCH] fix(gh): show fallback note when body fully filtered; fix api truncation Two fixes in gh_cmd.rs: 1. view_pr() and view_issue(): when filter_markdown_body() returns an empty string (body contained only badges, images, or HTML comments), the body was silently skipped. Now shows a note so the user knows content existed but was filtered. 2. run_api() non-JSON fallback: replaced naive .take(20) + double iteration with a single pass that shows line count in the truncation message ("... N more lines"), consistent with the rest of the module. Co-Authored-By: Claude Sonnet 4.6 --- src/gh_cmd.rs | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/gh_cmd.rs b/src/gh_cmd.rs index f52ed80d..64941aa3 100644 --- a/src/gh_cmd.rs +++ b/src/gh_cmd.rs @@ -382,6 +382,10 @@ fn view_pr(args: &[String], _verbose: u8, ultra_compact: bool) -> Result<()> { filtered.push_str(&formatted); print!("{}", formatted); } + } else { + let note = " (body contained only badges/images/comments)\n"; + filtered.push_str(note); + print!("{}", note); } } } @@ -678,6 +682,10 @@ fn view_issue(args: &[String], _verbose: u8) -> Result<()> { filtered.push_str(&formatted); print!("{}", formatted); } + } else { + let note = " (body contained only badges/images/comments)\n"; + filtered.push_str(note); + print!("{}", note); } } } @@ -1147,14 +1155,18 @@ fn run_api(args: &[String], _verbose: u8) -> Result<()> { } Err(_) => { // Not JSON, print truncated raw output + let all_lines: Vec<&str> = raw.lines().collect(); + let total = all_lines.len(); let mut result = String::new(); - let lines: Vec<&str> = raw.lines().take(20).collect(); - let joined = lines.join("\n"); - result.push_str(&joined); - print!("{}", joined); - if raw.lines().count() > 20 { - result.push_str("\n... (truncated)"); - println!("\n... (truncated)"); + for line in all_lines.iter().take(20) { + result.push_str(line); + result.push('\n'); + println!("{}", line); + } + if total > 20 { + let note = format!("... {} more lines (use gh api for full output)\n", total - 20); + result.push_str(¬e); + print!("{}", note); } result }