Fix bug where write_to_file sometimes closed claude dev tab

This commit is contained in:
Saoud Rizwan 2024-09-05 09:28:00 -04:00
parent 54b423c15e
commit 93073512ce
2 changed files with 13 additions and 3 deletions

View File

@ -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.27",
"version": "1.5.28",
"icon": "icon.png",
"engines": {
"vscode": "^1.84.0"

View File

@ -875,15 +875,25 @@ export class ClaudeDev {
// ensure that the in-memory doc is active editor (this seems to fail on windows machines if its already active, so ignoring if there's an error as it's likely it's already active anyways)
try {
await vscode.window.showTextDocument(inMemoryDocument, {
preview: true,
preview: false, // ensures it opens in non-preview tab (preview tabs are easily replaced)
preserveFocus: false,
})
// await vscode.window.showTextDocument(inMemoryDocument.uri, { preview: true, preserveFocus: false })
} catch (error) {
console.log(`Could not open editor for ${absolutePath}: ${error}`)
}
// Wait for the in-memory document to become the active editor (sometimes vscode timing issues happen and this would accidentally close claude dev!)
await pWaitFor(
() => {
return vscode.window.activeTextEditor?.document === inMemoryDocument
},
{ timeout: 5000, interval: 100 }
)
if (vscode.window.activeTextEditor?.document === inMemoryDocument) {
await vscode.commands.executeCommand("workbench.action.revertAndCloseActiveEditor") // allows us to close the untitled doc without being prompted to save it
}
await vscode.commands.executeCommand("workbench.action.revertAndCloseActiveEditor") // allows us to close the untitled doc without being prompted to save it
await this.closeDiffViews()
}