Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "Bug Fix",
"description": "Inline chat: reset the accept/reject state (code lenses and Enter shortcut) when the file being edited is deleted, so the IDE no longer gets stuck"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,28 @@ export class InlineChatController {
this.computeDiffAndRenderOnEditor = Experiments.instance.get('amazonqLSPInlineChat', false)
? this.computeDiffAndRenderOnEditorLSP.bind(this)
: this.computeDiffAndRenderOnEditorLocal.bind(this)

// If the file backing an active inline task is deleted, the task can no longer be
// accepted or rejected (its editor is gone), which would otherwise leave the
// accept/reject code lenses and the Enter-key shortcut context stuck until the IDE
// window is reopened. Clean up the inline task when its document is deleted.
context.subscriptions.push(
vscode.workspace.onDidDeleteFiles(async (event) => {
for (const uri of event.files) {
await this.cancelActiveTaskForDeletedDocument(uri)
}
})
)
}

/**
* Resets the inline chat state if the currently active task's document was deleted,
* so the code lenses and the Enter-key shortcut context do not get stuck.
*/
private async cancelActiveTaskForDeletedDocument(uri: vscode.Uri): Promise<void> {
if (this.task?.isActiveState() === true && this.task.document.uri.toString() === uri.toString()) {
await this.handleError()
}
}

public async createTask(
Expand Down
Loading