Browse Source

Fix issue where claude removes newline at end of files

Saoud Rizwan 1 year ago
parent
commit
1d305b66c1
3 changed files with 7 additions and 3 deletions
  1. 2 2
      package-lock.json
  2. 1 1
      package.json
  3. 4 0
      src/ClaudeDev.ts

+ 2 - 2
package-lock.json

@@ -1,12 +1,12 @@
 {
   "name": "claude-dev",
-  "version": "1.0.81",
+  "version": "1.0.82",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "claude-dev",
-      "version": "1.0.81",
+      "version": "1.0.82",
       "license": "MIT",
       "dependencies": {
         "@anthropic-ai/sdk": "^0.24.3",

+ 1 - 1
package.json

@@ -2,7 +2,7 @@
   "name": "claude-dev",
   "displayName": "Claude Dev",
   "description": "Autonomous software engineer right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.",
-  "version": "1.0.81",
+  "version": "1.0.82",
   "icon": "icon.png",
   "engines": {
     "vscode": "^1.84.0"

+ 4 - 0
src/ClaudeDev.ts

@@ -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