Show the inmemory doc in the proper view column when opening

This commit is contained in:
Saoud Rizwan
2024-09-04 12:38:06 -04:00
parent 22474f8cb9
commit 6bdb70a9ba
2 changed files with 24 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
"name": "claude-dev", "name": "claude-dev",
"displayName": "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.", "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.24", "version": "1.5.25",
"icon": "icon.png", "icon": "icon.png",
"engines": { "engines": {
"vscode": "^1.84.0" "vscode": "^1.84.0"

View File

@@ -863,12 +863,30 @@ export class ClaudeDev {
} }
const { response, text, images } = userResponse const { response, text, images } = userResponse
if (response !== "yesButtonTapped") { const closeInMemoryDocAndDiffViews = async () => {
// 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 { try {
await vscode.window.showTextDocument(inMemoryDocument.uri, { preview: true, preserveFocus: false }) const matchingEditor = vscode.window.visibleTextEditors.find(
} catch {} (editor) => editor.document.uri === inMemoryDocument.uri
await vscode.commands.executeCommand("workbench.action.revertAndCloseActiveEditor") )
if (matchingEditor) {
await vscode.window.showTextDocument(matchingEditor.document, {
viewColumn: matchingEditor.viewColumn,
preview: true,
preserveFocus: false,
})
}
// await vscode.window.showTextDocument(inMemoryDocument.uri, { preview: true, preserveFocus: false })
} catch (error) {
console.log(`Could not open editor for ${absolutePath}: ${error}`)
}
await vscode.commands.executeCommand("workbench.action.revertAndCloseActiveEditor") // allows us to close the untitled doc without being prompted to save it
await this.closeDiffViews() await this.closeDiffViews()
}
if (response !== "yesButtonTapped") {
await closeInMemoryDocAndDiffViews()
if (response === "messageResponse") { if (response === "messageResponse") {
await this.say("user_feedback", text, images) await this.say("user_feedback", text, images)
return this.formatIntoToolResponse(await this.formatGenericToolFeedback(text), images) return this.formatIntoToolResponse(await this.formatGenericToolFeedback(text), images)
@@ -883,15 +901,7 @@ export class ClaudeDev {
} }
await fs.writeFile(absolutePath, editedContent) await fs.writeFile(absolutePath, editedContent)
// Close the in-memory doc await closeInMemoryDocAndDiffViews()
try {
await vscode.window.showTextDocument(inMemoryDocument.uri, { preview: true, preserveFocus: false })
} catch (error) {
console.log(`Could not open editor for ${absolutePath}: ${error}`)
}
await vscode.commands.executeCommand("workbench.action.revertAndCloseActiveEditor")
await this.closeDiffViews()
// Finish by opening the edited file in the editor // Finish by opening the edited file in the editor
// calling showTextDocument would sometimes fail even though changes were applied, so we'll ignore these one-off errors (likely due to vscode locking issues) // calling showTextDocument would sometimes fail even though changes were applied, so we'll ignore these one-off errors (likely due to vscode locking issues)