@@ -127,9 +127,17 @@ export class TerminalViewPane extends ViewPane {
127127 return ( decorationsEnabled === 'both' || decorationsEnabled === 'gutter' ) && this . _configurationService . getValue ( TerminalSettingId . ShellIntegrationEnabled ) ;
128128 }
129129
130- private _initializeTerminal ( ) {
131- if ( this . isBodyVisible ( ) && this . _terminalService . isProcessSupportRegistered && this . _terminalService . connectionState === TerminalConnectionState . Connected && this . _terminalService . restoredGroupCount === 0 && this . _terminalGroupService . groups . length === 0 ) {
132- this . _terminalService . createTerminal ( { location : TerminalLocation . Panel } ) ;
130+ private _initializeTerminal ( checkRestoredTerminals : boolean ) {
131+ if ( this . isBodyVisible ( ) && this . _terminalService . isProcessSupportRegistered && this . _terminalService . connectionState === TerminalConnectionState . Connected ) {
132+ let shouldCreate = this . _terminalGroupService . groups . length === 0 ;
133+ // When triggered just after reconnection, also check there are no groups that could be
134+ // getting restored currently
135+ if ( checkRestoredTerminals ) {
136+ shouldCreate &&= this . _terminalService . restoredGroupCount === 0 ;
137+ }
138+ if ( shouldCreate ) {
139+ this . _terminalService . createTerminal ( { location : TerminalLocation . Panel } ) ;
140+ }
133141 }
134142 }
135143
@@ -169,7 +177,7 @@ export class TerminalViewPane extends ViewPane {
169177 if ( ! this . _terminalService . isProcessSupportRegistered ) {
170178 this . _onDidChangeViewWelcomeState . fire ( ) ;
171179 }
172- this . _initializeTerminal ( ) ;
180+ this . _initializeTerminal ( false ) ;
173181 // we don't know here whether or not it should be focused, so
174182 // defer focusing the panel to the focus() call
175183 // to prevent overriding preserveFocus for extensions
@@ -181,7 +189,7 @@ export class TerminalViewPane extends ViewPane {
181189 }
182190 this . _terminalGroupService . updateVisibility ( ) ;
183191 } ) ) ;
184- this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( ) ) ) ;
192+ this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( true ) ) ) ;
185193 this . layoutBody ( this . _parentDomElement . offsetHeight , this . _parentDomElement . offsetWidth ) ;
186194 }
187195
0 commit comments