File tree Expand file tree Collapse file tree
src/vs/workbench/contrib/terminal/browser Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments