Fix issue where claude removes newline at end of files

This commit is contained in:
Saoud Rizwan
2024-07-31 21:30:42 -04:00
parent 5eb0c65419
commit 1d305b66c1
3 changed files with 7 additions and 3 deletions

View File

@@ -369,6 +369,10 @@ export class ClaudeDev {
.catch(() => false)
if (fileExists) {
const originalContent = await fs.readFile(filePath, "utf-8")
// fix issue where claude always removes newline from the file
if (originalContent.endsWith("\n") && !newContent.endsWith("\n")) {
newContent += "\n"
}
// condensed patch to return to claude
const diffResult = diff.createPatch(filePath, originalContent, newContent)
// full diff representation for webview