@@ -127,9 +127,17 @@ export class TerminalViewPane extends ViewPane {
127
127
return ( decorationsEnabled === 'both' || decorationsEnabled === 'gutter' ) && this . _configurationService . getValue ( TerminalSettingId . ShellIntegrationEnabled ) ;
128
128
}
129
129
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
+ }
133
141
}
134
142
}
135
143
@@ -169,7 +177,7 @@ export class TerminalViewPane extends ViewPane {
169
177
if ( ! this . _terminalService . isProcessSupportRegistered ) {
170
178
this . _onDidChangeViewWelcomeState . fire ( ) ;
171
179
}
172
- this . _initializeTerminal ( ) ;
180
+ this . _initializeTerminal ( false ) ;
173
181
// we don't know here whether or not it should be focused, so
174
182
// defer focusing the panel to the focus() call
175
183
// to prevent overriding preserveFocus for extensions
@@ -181,7 +189,7 @@ export class TerminalViewPane extends ViewPane {
181
189
}
182
190
this . _terminalGroupService . updateVisibility ( ) ;
183
191
} ) ) ;
184
- this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( ) ) ) ;
192
+ this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( true ) ) ) ;
185
193
this . layoutBody ( this . _parentDomElement . offsetHeight , this . _parentDomElement . offsetWidth ) ;
186
194
}
187
195
0 commit comments