Skip to content

Commit e37e0ff

Browse files
authored
Adjust active terminal tab when active tab moves (#106413)
Fixes #106300
1 parent e73d3a8 commit e37e0ff

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ export class TerminalService implements ITerminalService {
232232
private _removeTab(tab: ITerminalTab): void {
233233
// Get the index of the tab and remove it from the list
234234
const index = this._terminalTabs.indexOf(tab);
235-
const wasActiveTab = tab === this.getActiveTab();
235+
const activeTab = this.getActiveTab();
236+
const activeTabIndex = activeTab ? this._terminalTabs.indexOf(activeTab) : -1;
237+
const wasActiveTab = tab === activeTab;
236238
if (index !== -1) {
237239
this._terminalTabs.splice(index, 1);
238240
}
@@ -247,6 +249,9 @@ export class TerminalService implements ITerminalService {
247249
if (activeInstance) {
248250
activeInstance.focus(true);
249251
}
252+
} else if (activeTabIndex >= this._terminalTabs.length) {
253+
const newIndex = this._terminalTabs.length - 1;
254+
this.setActiveTabByIndex(newIndex);
250255
}
251256

252257
// Hide the panel if there are no more instances, provided that VS Code is not shutting

0 commit comments

Comments
 (0)