@@ -317,43 +317,41 @@ class LocalTerminalBackend extends BaseTerminalBackend implements ITerminalBacke
317
317
318
318
// Revive processes if needed
319
319
const serializedState = this . _storageService . get ( TerminalStorageKeys . TerminalBufferState , StorageScope . WORKSPACE ) ;
320
- const parsed = this . _deserializeTerminalState ( serializedState ) ;
321
- if ( ! parsed ) {
322
- return undefined ;
323
- }
324
-
325
- try {
326
- // Create variable resolver
327
- const activeWorkspaceRootUri = this . _historyService . getLastActiveWorkspaceRoot ( ) ;
328
- const lastActiveWorkspace = activeWorkspaceRootUri ? withNullAsUndefined ( this . _workspaceContextService . getWorkspaceFolder ( activeWorkspaceRootUri ) ) : undefined ;
329
- const variableResolver = terminalEnvironment . createVariableResolver ( lastActiveWorkspace , await this . _terminalProfileResolverService . getEnvironment ( this . remoteAuthority ) , this . _configurationResolverService ) ;
330
-
331
- // Re-resolve the environments and replace it on the state so local terminals use a fresh
332
- // environment
333
- mark ( 'code/terminal/willGetReviveEnvironments' ) ;
334
- await Promise . all ( parsed . map ( state => new Promise < void > ( r => {
335
- this . _resolveEnvironmentForRevive ( variableResolver , state . shellLaunchConfig ) . then ( freshEnv => {
336
- state . processLaunchConfig . env = freshEnv ;
337
- r ( ) ;
338
- } ) ;
339
- } ) ) ) ;
340
- mark ( 'code/terminal/didGetReviveEnvironments' ) ;
341
-
342
- mark ( 'code/terminal/willReviveTerminalProcesses' ) ;
343
- await this . _proxy . reviveTerminalProcesses ( workspaceId , parsed , Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale ) ;
344
- mark ( 'code/terminal/didReviveTerminalProcesses' ) ;
345
- this . _storageService . remove ( TerminalStorageKeys . TerminalBufferState , StorageScope . WORKSPACE ) ;
346
- // If reviving processes, send the terminal layout info back to the pty host as it
347
- // will not have been persisted on application exit
348
- const layoutInfo = this . _storageService . get ( TerminalStorageKeys . TerminalLayoutInfo , StorageScope . WORKSPACE ) ;
349
- if ( layoutInfo ) {
350
- mark ( 'code/terminal/willSetTerminalLayoutInfo' ) ;
351
- await this . _proxy . setTerminalLayoutInfo ( JSON . parse ( layoutInfo ) ) ;
352
- mark ( 'code/terminal/didSetTerminalLayoutInfo' ) ;
353
- this . _storageService . remove ( TerminalStorageKeys . TerminalLayoutInfo , StorageScope . WORKSPACE ) ;
320
+ const reviveBufferState = this . _deserializeTerminalState ( serializedState ) ;
321
+ if ( reviveBufferState && reviveBufferState . length > 0 ) {
322
+ try {
323
+ // Create variable resolver
324
+ const activeWorkspaceRootUri = this . _historyService . getLastActiveWorkspaceRoot ( ) ;
325
+ const lastActiveWorkspace = activeWorkspaceRootUri ? withNullAsUndefined ( this . _workspaceContextService . getWorkspaceFolder ( activeWorkspaceRootUri ) ) : undefined ;
326
+ const variableResolver = terminalEnvironment . createVariableResolver ( lastActiveWorkspace , await this . _terminalProfileResolverService . getEnvironment ( this . remoteAuthority ) , this . _configurationResolverService ) ;
327
+
328
+ // Re-resolve the environments and replace it on the state so local terminals use a fresh
329
+ // environment
330
+ mark ( 'code/terminal/willGetReviveEnvironments' ) ;
331
+ await Promise . all ( reviveBufferState . map ( state => new Promise < void > ( r => {
332
+ this . _resolveEnvironmentForRevive ( variableResolver , state . shellLaunchConfig ) . then ( freshEnv => {
333
+ state . processLaunchConfig . env = freshEnv ;
334
+ r ( ) ;
335
+ } ) ;
336
+ } ) ) ) ;
337
+ mark ( 'code/terminal/didGetReviveEnvironments' ) ;
338
+
339
+ mark ( 'code/terminal/willReviveTerminalProcesses' ) ;
340
+ await this . _proxy . reviveTerminalProcesses ( workspaceId , reviveBufferState , Intl . DateTimeFormat ( ) . resolvedOptions ( ) . locale ) ;
341
+ mark ( 'code/terminal/didReviveTerminalProcesses' ) ;
342
+ this . _storageService . remove ( TerminalStorageKeys . TerminalBufferState , StorageScope . WORKSPACE ) ;
343
+ // If reviving processes, send the terminal layout info back to the pty host as it
344
+ // will not have been persisted on application exit
345
+ const layoutInfo = this . _storageService . get ( TerminalStorageKeys . TerminalLayoutInfo , StorageScope . WORKSPACE ) ;
346
+ if ( layoutInfo ) {
347
+ mark ( 'code/terminal/willSetTerminalLayoutInfo' ) ;
348
+ await this . _proxy . setTerminalLayoutInfo ( JSON . parse ( layoutInfo ) ) ;
349
+ mark ( 'code/terminal/didSetTerminalLayoutInfo' ) ;
350
+ this . _storageService . remove ( TerminalStorageKeys . TerminalLayoutInfo , StorageScope . WORKSPACE ) ;
351
+ }
352
+ } catch ( e : unknown ) {
353
+ this . _logService . warn ( 'LocalTerminalBackend#getTerminalLayoutInfo Error' , e && typeof e === 'object' && 'message' in e ? e . message : e ) ;
354
354
}
355
- } catch ( e : unknown ) {
356
- this . _logService . warn ( 'LocalTerminalBackend#getTerminalLayoutInfo Error' , e && typeof e === 'object' && 'message' in e ? e . message : e ) ;
357
355
}
358
356
359
357
return this . _proxy . getTerminalLayoutInfo ( layoutArgs ) ;
0 commit comments