diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts index df71e4f6b62..c8c01392dce 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/terminal.test.ts @@ -25,6 +25,8 @@ import { assertNoRpc } from '../utils'; await config.update('showExitAlert', false, ConfigurationTarget.Global); // Canvas may cause problems when running in a container await config.update('rendererType', 'dom', ConfigurationTarget.Global); + // Disable env var relaunch for tests to prevent terminals relaunching themselves + await config.update('environmentChangesRelaunch', false, ConfigurationTarget.Global); }); suite('Terminal', () => { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index c782675bc61..f5e2c96180b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1566,7 +1566,15 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // Recreate the process if the terminal has not yet been interacted with and it's not a // special terminal (eg. task, extension terminal) - if (info.requiresAction && !this._processManager.hasWrittenData && !this._shellLaunchConfig.isFeatureTerminal && !this._shellLaunchConfig.isExtensionCustomPtyTerminal && !this._shellLaunchConfig.isExtensionOwnedTerminal && !this._shellLaunchConfig.attachPersistentProcess) { + if ( + info.requiresAction && + this._configHelper.config.environmentChangesRelaunch && + !this._processManager.hasWrittenData && + !this._shellLaunchConfig.isFeatureTerminal && + !this._shellLaunchConfig.isExtensionCustomPtyTerminal + && !this._shellLaunchConfig.isExtensionOwnedTerminal && + !this._shellLaunchConfig.attachPersistentProcess + ) { this.relaunch(); return; } diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index dff256e9500..004f39ba065 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -130,6 +130,7 @@ export interface ITerminalConfiguration { windows: { [key: string]: string }; }; environmentChangesIndicator: 'off' | 'on' | 'warnonly'; + environmentChangesRelaunch: boolean; showExitAlert: boolean; splitCwd: 'workspaceRoot' | 'initial' | 'inherited'; windowsEnableConpty: boolean; diff --git a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts index d275d0afa00..b4ddfa8a6d4 100644 --- a/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts +++ b/src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts @@ -311,6 +311,11 @@ export const terminalConfiguration: IConfigurationNode = { ], default: 'warnonly' }, + 'terminal.integrated.environmentChangesRelaunch': { + markdownDescription: localize('terminal.integrated.environmentChangesRelaunch', "Whether to relaunch terminals automatically if extension want to contribute to their environment and have not been interacted with yet."), + type: 'boolean', + default: true + }, 'terminal.integrated.showExitAlert': { description: localize('terminal.integrated.showExitAlert', "Controls whether to show the alert \"The terminal process terminated with exit code\" when exit code is non-zero."), type: 'boolean',