Skip to content

Commit ff2cce6

Browse files
yogeshwaran-cclaude
andcommitted
feat(terminal): add Kill Other Terminals command
Adds a new `workbench.action.terminal.killOthers` command that kills all terminals except the currently active one, mirroring the existing "Close Others" action available in the editor tab context menu. Fixes microsoft#295740 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1da74cc commit ff2cce6

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/vs/workbench/contrib/terminal/browser/terminalActions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,25 @@ export function registerTerminalActions() {
13021302
}
13031303
});
13041304

1305+
registerTerminalAction({
1306+
id: TerminalCommandId.KillOthers,
1307+
title: localize2('workbench.action.terminal.killOthers', 'Kill Other Terminals'),
1308+
precondition: ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen),
1309+
run: async (c) => {
1310+
const activeInstance = c.service.activeInstance;
1311+
if (!activeInstance) {
1312+
return;
1313+
}
1314+
const disposePromises: Promise<void>[] = [];
1315+
for (const instance of c.service.instances) {
1316+
if (instance !== activeInstance) {
1317+
disposePromises.push(c.service.safeDisposeTerminal(instance));
1318+
}
1319+
}
1320+
await Promise.all(disposePromises);
1321+
}
1322+
});
1323+
13051324
registerTerminalAction({
13061325
id: TerminalCommandId.KillEditor,
13071326
title: localize2('workbench.action.terminal.killEditor', 'Kill the Active Terminal in Editor Area'),

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ export const enum TerminalCommandId {
408408
KillEditor = 'workbench.action.terminal.killEditor',
409409
KillActiveTab = 'workbench.action.terminal.killActiveTab',
410410
KillAll = 'workbench.action.terminal.killAll',
411+
KillOthers = 'workbench.action.terminal.killOthers',
411412
QuickKill = 'workbench.action.terminal.quickKill',
412413
ConfigureTerminalSettings = 'workbench.action.terminal.openSettings',
413414
ShellIntegrationLearnMore = 'workbench.action.terminal.learnMore',

0 commit comments

Comments
 (0)