Skip to content

Commit 6e9e3b1

Browse files
committed
Implement tab closing logic when deleting files after accepting a chat response
1 parent 76d59fe commit 6e9e3b1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,22 @@ export const apply_chat_response_command = (
226226

227227
if (accepted_state.is_deleted) {
228228
if (fs.existsSync(sanitized_file_path)) {
229+
const tabs_to_close: vscode.Tab[] = []
230+
for (const tab_group of vscode.window.tabGroups.all) {
231+
tabs_to_close.push(
232+
...tab_group.tabs.filter((tab) => {
233+
const tab_uri = (tab.input as any)?.uri as
234+
| vscode.Uri
235+
| undefined
236+
return tab_uri && tab_uri.fsPath == sanitized_file_path
237+
})
238+
)
239+
}
240+
241+
if (tabs_to_close.length > 0) {
242+
await vscode.window.tabGroups.close(tabs_to_close)
243+
}
244+
229245
await vscode.workspace.fs.delete(
230246
vscode.Uri.file(sanitized_file_path)
231247
)

0 commit comments

Comments
 (0)