From 683abb1ac3710a8841871e63076eef40c39edd80 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:07:32 -0400 Subject: [PATCH] Close diff view even if it loses focus --- src/ClaudeDev.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/ClaudeDev.ts b/src/ClaudeDev.ts index 97d9ccc..0883d57 100644 --- a/src/ClaudeDev.ts +++ b/src/ClaudeDev.ts @@ -408,10 +408,13 @@ export class ClaudeDev { diff: diffRepresentation, } as ClaudeSayTool) ) - // close the diff view if it's open - if (vscode.window.activeTextEditor?.document.uri.scheme === "claude-dev-diff") { - await vscode.commands.executeCommand("workbench.action.closeActiveEditor") - } + // close the diff view + vscode.workspace.textDocuments + .filter((doc) => doc.uri.scheme === "claude-dev-diff") + .forEach(async (doc) => { + await vscode.window.showTextDocument(doc.uri, { preserveFocus: false, preview: true }) + await vscode.commands.executeCommand("workbench.action.closeActiveEditor") + }) if (response !== "yesButtonTapped") { if (response === "textResponse" && text) { await this.say("user_feedback", text) @@ -441,9 +444,12 @@ export class ClaudeDev { "tool", JSON.stringify({ tool: "newFileCreated", path: filePath, content: newContent } as ClaudeSayTool) ) - if (vscode.window.activeTextEditor?.document.uri.scheme === "claude-dev-diff") { - await vscode.commands.executeCommand("workbench.action.closeActiveEditor") - } + vscode.workspace.textDocuments + .filter((doc) => doc.uri.scheme === "claude-dev-diff") + .forEach(async (doc) => { + await vscode.window.showTextDocument(doc.uri, { preserveFocus: false, preview: true }) + await vscode.commands.executeCommand("workbench.action.closeActiveEditor") + }) if (response !== "yesButtonTapped") { if (response === "textResponse" && text) { await this.say("user_feedback", text)