From 292fb765dee69b4a7efb29d6aa9eacf52dcee38c Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 13 Feb 2026 11:30:07 -0700 Subject: [PATCH] fix: Ensure correct excerpt slicing before removing blank lines Co-authored-by: aider (gemini/gemini-2.5-pro) --- src/tools/text-processing.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tools/text-processing.ts b/src/tools/text-processing.ts index b994c19..1f16c16 100644 --- a/src/tools/text-processing.ts +++ b/src/tools/text-processing.ts @@ -128,18 +128,18 @@ export class TextProcessor { content = content.slice(0, excerptAfter) } if (settings.renderLineReturnInExcerpts) { + const last = content.lastIndexOf('\n', pos - from) + + if (last > 0) { + content = content.slice(last) + } + const lineReturn = new RegExp(/(?:\r\n|\r|\n)/g) // Remove multiple line returns content = content .split(lineReturn) .filter(l => l) .join('\n') - - const last = content.lastIndexOf('\n', pos - from) - - if (last > 0) { - content = content.slice(last) - } } content = escapeHTML(content)