Fix shell tool output line clipping to account for suffix

The shell tool output line was wrapping because update_tool_output_line
clipped the content without reserving space for the suffix that gets
appended later (line count + timing info).

Added suffix_overhead of 30 chars for shell tools to reserve space for:
- " (9999 lines)" = ~13 chars
- " | 99999 ◉ 999ms" = ~17 chars

This ensures the complete line fits within terminal width without wrapping.
This commit is contained in:
Dhanji R. Prasanna
2026-02-05 21:23:00 +11:00
parent 7e2d9bc22c
commit c6df75d886

View File

@@ -418,7 +418,14 @@ impl UiWriter for ConsoleUiWriter {
let mut line_printed = self.output_line_printed.lock().unwrap(); let mut line_printed = self.output_line_printed.lock().unwrap();
let is_shell = *self.is_shell_compact.lock().unwrap(); let is_shell = *self.is_shell_compact.lock().unwrap();
let prefix_width = if is_shell { 6 } else { 3 }; let prefix_width = if is_shell { 6 } else { 3 };
let max_content_width = get_terminal_width().saturating_sub(prefix_width); // For shell, reserve space for suffix: " (N lines) | N ◉ Xms"
// - " (9999 lines)" = 13 chars max
// - " | 99999 ◉ 999ms" = 17 chars max
// Total suffix overhead: ~30 chars
let suffix_overhead = if is_shell { 30 } else { 0 };
let max_content_width = get_terminal_width()
.saturating_sub(prefix_width)
.saturating_sub(suffix_overhead);
// If we've already printed a line, clear it first // If we've already printed a line, clear it first
if *line_printed { if *line_printed {