From 23740b45de3233e6ab181435669e9c305d63a50d Mon Sep 17 00:00:00 2001 From: Ray Tien Date: Thu, 1 Oct 2026 17:09:00 +0800 Subject: [PATCH] fix(pi-fff): keep collapsed result row within available width CollapsedText appended the full "..." marker even when the preview had no room left, so the row could be up to 3 columns wider than the width it was given. In pi this makes the TUI throw "Rendered line N exceeds terminal width" and exit (seen at 24 columns with a 217-line ffgrep result). When previewWidth < markerWidth, return only the suffix. Co-Authored-By: Claude Sonnet 5.5 --- packages/pi-fff/src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/pi-fff/src/index.ts b/packages/pi-fff/src/index.ts index 0d0d61bc1..19664b2ab 100644 --- a/packages/pi-fff/src/index.ts +++ b/packages/pi-fff/src/index.ts @@ -891,8 +891,9 @@ export default function fffExtension(pi: ExtensionAPI) { } const markerWidth = visibleWidth(this.marker); + if (previewWidth < markerWidth) return [this.suffix]; return [ - `${sliceByColumn(this.preview, 0, Math.max(0, previewWidth - markerWidth), true)}${this.marker} ${this.suffix}`, + `${sliceByColumn(this.preview, 0, previewWidth - markerWidth, true)}${this.marker} ${this.suffix}`, ]; }