@@ -73,6 +73,8 @@ import { TerminalCapability } from 'vs/workbench/contrib/terminal/common/capabil
73
73
import { ITextModel } from 'vs/editor/common/model' ;
74
74
import { IModelService } from 'vs/editor/common/services/model' ;
75
75
import { ITextModelContentProvider , ITextModelService } from 'vs/editor/common/services/resolverService' ;
76
+ import { IHistoryService } from 'vs/workbench/services/history/common/history' ;
77
+ import { Schemas } from 'vs/base/common/network' ;
76
78
77
79
const enum Constants {
78
80
/**
@@ -350,7 +352,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
350
352
@IWorkbenchEnvironmentService workbenchEnvironmentService : IWorkbenchEnvironmentService ,
351
353
@IWorkspaceContextService private readonly _workspaceContextService : IWorkspaceContextService ,
352
354
@IEditorService private readonly _editorService : IEditorService ,
353
- @IWorkspaceTrustRequestService private readonly _workspaceTrustRequestService : IWorkspaceTrustRequestService
355
+ @IWorkspaceTrustRequestService private readonly _workspaceTrustRequestService : IWorkspaceTrustRequestService ,
356
+ @IHistoryService private readonly _historyService : IHistoryService
354
357
) {
355
358
super ( ) ;
356
359
@@ -1312,9 +1315,16 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
1312
1315
if ( this . _isDisposed ) {
1313
1316
return ;
1314
1317
}
1315
-
1316
- const trusted = await this . _trust ( ) ;
1317
- if ( ! trusted ) {
1318
+ const activeWorkspaceRootUri = this . _historyService . getLastActiveWorkspaceRoot ( Schemas . file ) ;
1319
+ if ( activeWorkspaceRootUri ) {
1320
+ const trusted = await this . _trust ( ) ;
1321
+ if ( ! trusted ) {
1322
+ this . _onProcessExit ( { message : nls . localize ( 'workspaceNotTrustedCreateTerminal' , "Cannot launch a terminal process in an untrusted workspace" ) } ) ;
1323
+ }
1324
+ } else if ( this . _userHome && this . _cwd !== this . _userHome ) {
1325
+ // ensure that the process is launched in userHome for an empty workspace
1326
+ this . _shellLaunchConfig . cwd = this . _userHome ;
1327
+ } else if ( ! this . _userHome ) {
1318
1328
this . _onProcessExit ( { message : nls . localize ( 'workspaceNotTrustedCreateTerminal' , "Cannot launch a terminal process in an untrusted workspace" ) } ) ;
1319
1329
}
1320
1330
0 commit comments