From e91ea3ac1ab37eac715e1f4451f8d980620939f8 Mon Sep 17 00:00:00 2001 From: yiliang114 <1204183885@qq.com> Date: Tue, 9 Dec 2025 15:53:41 +0800 Subject: [PATCH] refactor(vscode-ide-companion): simplify openDiff tool implementation - Remove redundant file reading logic from ide-server - Leverage diffManager's new capability to read old content internally - Simplify openDiff tool call site to pass only newContent - Update comments to reflect the simplified implementation --- packages/vscode-ide-companion/src/ide-server.ts | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/vscode-ide-companion/src/ide-server.ts b/packages/vscode-ide-companion/src/ide-server.ts index 98fafc98..8324f802 100644 --- a/packages/vscode-ide-companion/src/ide-server.ts +++ b/packages/vscode-ide-companion/src/ide-server.ts @@ -437,18 +437,8 @@ const createMcpServer = (diffManager: DiffManager) => { inputSchema: OpenDiffRequestSchema.shape, }, async ({ filePath, newContent }: z.infer) => { - // Read old content if file exists, otherwise use empty string - let oldContent = ''; - try { - const fileUri = vscode.Uri.file(filePath); - const document = await vscode.workspace.openTextDocument(fileUri); - oldContent = document.getText(); - } catch (_error) { - // File doesn't exist, use empty string (creating new file) - oldContent = ''; - } - - await diffManager.showDiff(filePath, oldContent, newContent); + // Minimal call site: only pass newContent; DiffManager reads old content itself + await diffManager.showDiff(filePath, newContent); return { content: [] }; }, );