@@ -125,9 +125,17 @@ export class TerminalViewPane extends ViewPane {
125
125
return ( decorationsEnabled === 'both' || decorationsEnabled === 'gutter' ) && this . _configurationService . getValue ( TerminalSettingId . ShellIntegrationEnabled ) ;
126
126
}
127
127
128
- private _initializeTerminal ( ) {
129
- if ( this . isBodyVisible ( ) && this . _terminalService . isProcessSupportRegistered && this . _terminalService . connectionState === TerminalConnectionState . Connected && this . _terminalService . restoredGroupCount === 0 && this . _terminalGroupService . groups . length === 0 ) {
130
- this . _terminalService . createTerminal ( { location : TerminalLocation . Panel } ) ;
128
+ private _initializeTerminal ( checkRestoredTerminals : boolean ) {
129
+ if ( this . isBodyVisible ( ) && this . _terminalService . isProcessSupportRegistered && this . _terminalService . connectionState === TerminalConnectionState . Connected ) {
130
+ let shouldCreate = this . _terminalGroupService . groups . length === 0 ;
131
+ // When triggered just after reconnection, also check there are no groups that could be
132
+ // getting restored currently
133
+ if ( checkRestoredTerminals ) {
134
+ shouldCreate &&= this . _terminalService . restoredGroupCount === 0 ;
135
+ }
136
+ if ( shouldCreate ) {
137
+ this . _terminalService . createTerminal ( { location : TerminalLocation . Panel } ) ;
138
+ }
131
139
}
132
140
}
133
141
@@ -167,7 +175,7 @@ export class TerminalViewPane extends ViewPane {
167
175
if ( ! this . _terminalService . isProcessSupportRegistered ) {
168
176
this . _onDidChangeViewWelcomeState . fire ( ) ;
169
177
}
170
- this . _initializeTerminal ( ) ;
178
+ this . _initializeTerminal ( false ) ;
171
179
// we don't know here whether or not it should be focused, so
172
180
// defer focusing the panel to the focus() call
173
181
// to prevent overriding preserveFocus for extensions
@@ -179,7 +187,7 @@ export class TerminalViewPane extends ViewPane {
179
187
}
180
188
this . _terminalGroupService . updateVisibility ( ) ;
181
189
} ) ) ;
182
- this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( ) ) ) ;
190
+ this . _register ( this . _terminalService . onDidChangeConnectionState ( ( ) => this . _initializeTerminal ( true ) ) ) ;
183
191
this . layoutBody ( this . _parentDomElement . offsetHeight , this . _parentDomElement . offsetWidth ) ;
184
192
}
185
193
0 commit comments