summaryrefslogtreecommitdiffhomepage
path: root/internal/llm/tools/edit.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-03 19:50:31 +0200
committerKujtim Hoxha <[email protected]>2025-04-03 19:50:31 +0200
commit49b593d9ddbe278358b30dcde444932172bea615 (patch)
treedbe6c779ca4932ff369f3684dbefd3e0e599e0fd /internal/llm/tools/edit.go
parent230917bbbf5fa2cbdb37f298554889a7a5233744 (diff)
downloadopencode-49b593d9ddbe278358b30dcde444932172bea615.tar.gz
opencode-49b593d9ddbe278358b30dcde444932172bea615.zip
small fixes
Diffstat (limited to 'internal/llm/tools/edit.go')
-rw-r--r--internal/llm/tools/edit.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/llm/tools/edit.go b/internal/llm/tools/edit.go
index a5877044b..f12a1eb21 100644
--- a/internal/llm/tools/edit.go
+++ b/internal/llm/tools/edit.go
@@ -260,7 +260,12 @@ func replaceContent(filePath, oldString, newString string) (string, error) {
}
newContent := oldContent[:index] + newString + oldContent[index+len(oldString):]
- diff := GenerateDiff(oldString, newContent)
+
+ startIndex := max(0, index-3)
+ oldEndIndex := min(len(oldContent), index+len(oldString)+3)
+ newEndIndex := min(len(newContent), index+len(newString)+3)
+
+ diff := GenerateDiff(oldContent[startIndex:oldEndIndex], newContent[startIndex:newEndIndex])
p := permission.Default.Request(
permission.CreatePermissionRequest{