Browse Source

Make diff view left side readonly so users don't accidentally edit it

Saoud Rizwan 1 year ago
parent
commit
3926d1c528
3 changed files with 5 additions and 7 deletions
  1. 1 1
      package.json
  2. 3 5
      src/ClaudeDev.ts
  3. 1 1
      src/extension.ts

+ 1 - 1
package.json

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

+ 3 - 5
src/ClaudeDev.ts

@@ -815,11 +815,9 @@ export class ClaudeDev {
 
 			vscode.commands.executeCommand(
 				"vscode.diff",
-				fileExists
-					? vscode.Uri.file(absolutePath)
-					: vscode.Uri.parse(`claude-dev-diff:${path.basename(absolutePath)}`).with({
-							query: Buffer.from("").toString("base64"),
-					  }),
+				vscode.Uri.parse(`claude-dev-diff:${path.basename(absolutePath)}`).with({
+					query: Buffer.from(originalContent).toString("base64"),
+				}),
 				vscode.Uri.file(tempFilePath),
 				`${path.basename(absolutePath)}: ${fileExists ? "Original ↔ Claude's Changes" : "New File"} (Editable)`
 			)

+ 1 - 1
src/extension.ts

@@ -94,7 +94,7 @@ export function activate(context: vscode.ExtensionContext) {
 	)
 
 	/*
-	We use the text document content provider API to show an empty text doc for diff view for new files by creating a virtual document for the new content.
+	We use the text document content provider API to show the left side for diff view by creating a virtual document for the original content. This makes it readonly so users know to edit the right side if they want to keep their changes.
 
 	- This API allows you to create readonly documents in VSCode from arbitrary sources, and works by claiming an uri-scheme for which your provider then returns text contents. The scheme must be provided when registering a provider and cannot change afterwards.
 	- Note how the provider doesn't create uris for virtual documents - its role is to provide contents given such an uri. In return, content providers are wired into the open document logic so that providers are always considered.