mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
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
This commit is contained in:
@@ -437,18 +437,8 @@ const createMcpServer = (diffManager: DiffManager) => {
|
|||||||
inputSchema: OpenDiffRequestSchema.shape,
|
inputSchema: OpenDiffRequestSchema.shape,
|
||||||
},
|
},
|
||||||
async ({ filePath, newContent }: z.infer<typeof OpenDiffRequestSchema>) => {
|
async ({ filePath, newContent }: z.infer<typeof OpenDiffRequestSchema>) => {
|
||||||
// Read old content if file exists, otherwise use empty string
|
// Minimal call site: only pass newContent; DiffManager reads old content itself
|
||||||
let oldContent = '';
|
await diffManager.showDiff(filePath, newContent);
|
||||||
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);
|
|
||||||
return { content: [] };
|
return { content: [] };
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user