summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorcvzakharchenko <[email protected]>2025-08-11 13:55:45 +0200
committerGitHub <[email protected]>2025-08-11 06:55:45 -0500
commit8db75266d0da48bfd1257d528373549dc0814584 (patch)
tree3d2b3cc97ef2a0e4ab7297885b813b6d64a7440e /packages
parent6c30565d40023d001f072d76a80ed3b14149499c (diff)
downloadopencode-8db75266d0da48bfd1257d528373549dc0814584.tar.gz
opencode-8db75266d0da48bfd1257d528373549dc0814584.zip
Issue 1676: Don't eat up the last newline in a multi-line replacement (#1777)
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/tool/edit.ts5
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/opencode/src/tool/edit.ts b/packages/opencode/src/tool/edit.ts
index d3883b539..1b31b0aa4 100644
--- a/packages/opencode/src/tool/edit.ts
+++ b/packages/opencode/src/tool/edit.ts
@@ -188,7 +188,10 @@ export const LineTrimmedReplacer: Replacer = function* (content, find) {
let matchEndIndex = matchStartIndex
for (let k = 0; k < searchLines.length; k++) {
- matchEndIndex += originalLines[i + k].length + 1
+ matchEndIndex += originalLines[i + k].length
+ if (k < searchLines.length - 1) {
+ matchEndIndex += 1 // Add newline character except for the last line
+ }
}
yield content.substring(matchStartIndex, matchEndIndex)