Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure that the second window always gets the same environment as the first one #202326

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/platform/environment/common/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface NativeParsedArgs {
'remote'?: string;
'force'?: boolean;
'do-not-sync'?: boolean;
'preserve-env'?: boolean;
'force-user-env'?: boolean;
'force-disable-user-env'?: boolean;
'sync'?: 'on' | 'off';
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/environment/node/argv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export const OPTIONS: OptionDescriptions<Required<NativeParsedArgs>> = {
'trace': { type: 'boolean' },
'trace-category-filter': { type: 'string' },
'trace-options': { type: 'string' },
'preserve-env': { type: 'boolean' },
'force-user-env': { type: 'boolean' },
'force-disable-user-env': { type: 'boolean' },
'open-devtools': { type: 'boolean' },
Expand Down
13 changes: 12 additions & 1 deletion src/vs/platform/launch/electron-main/launchMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,18 @@ export class LaunchMainService implements ILaunchMainService {
const baseConfig: IOpenConfiguration = {
context,
cli: args,
userEnv,
/**
* When opening a new window from a second instance that sent args and env
* over to this instance, we want to preserve the environment only if that second
* instance was spawned from the CLI or used the `--preserve-env` flag (example:
* when using `open -n "VSCode.app" --args --preserve-env WORKSPACE_FOLDER`).
*
* This is done to ensure that the second window gets treated exactly the same
* as the first window, for example, it gets the same resolved user shell environment.
*
* https://github.com/microsoft/vscode/issues/194736
*/
userEnv: (args['preserve-env'] || context === OpenContext.CLI) ? userEnv : undefined,
waitMarkerFileURI,
remoteAuthority,
forceProfile: args.profile,
Expand Down