Skip to content

Commit 02d3809

Browse files
committed
Allow undefined in terminal env map, unify interfaces
Note that this adds undefined as an option to TerminalOptions.env which could end up causing compile errors, but they will be more correct and could reveal a bug in an extension since some key could return undefined. Fixes #119046
1 parent a05c63d commit 02d3809

File tree

9 files changed

+28
-42
lines changed

9 files changed

+28
-42
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
77
import { Event } from 'vs/base/common/event';
88
import { IProcessEnvironment } from 'vs/base/common/platform';
9-
import { URI } from 'vs/base/common/uri';
9+
import { URI, UriComponents } from 'vs/base/common/uri';
1010
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
1111

1212
export enum WindowsShellType {
@@ -282,8 +282,17 @@ export interface IShellLaunchConfig {
282282
isExtensionOwnedTerminal?: boolean;
283283
}
284284

285+
export interface IShellLaunchConfigDto {
286+
name?: string;
287+
executable?: string;
288+
args?: string[] | string;
289+
cwd?: string | UriComponents;
290+
env?: ITerminalEnvironment;
291+
hideFromUser?: boolean;
292+
}
293+
285294
export interface ITerminalEnvironment {
286-
[key: string]: string | null;
295+
[key: string]: string | null | undefined;
287296
}
288297

289298
export interface ITerminalLaunchError {

src/vs/platform/terminal/common/terminalProcess.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ import { UriComponents } from 'vs/base/common/uri';
77
import { IRawTerminalTabLayoutInfo, ITerminalEnvironment, ITerminalTabLayoutInfoById } from 'vs/platform/terminal/common/terminal';
88
import { ISerializableEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable';
99

10-
export interface IShellLaunchConfigDto {
11-
name?: string;
12-
executable?: string;
13-
args?: string[] | string;
14-
cwd?: string | UriComponents;
15-
env?: { [key: string]: string | null; };
16-
hideFromUser?: boolean;
17-
}
18-
1910
export interface ISingleTerminalConfiguration<T> {
2011
userValue: T | undefined;
2112
value: T | undefined;

src/vs/vscode.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9272,7 +9272,7 @@ declare module 'vscode' {
92729272
/**
92739273
* Object with environment variables that will be added to the VS Code process.
92749274
*/
9275-
env?: { [key: string]: string | null };
9275+
env?: { [key: string]: string | null | undefined };
92769276

92779277
/**
92789278
* Whether the terminal process environment should be exactly as provided in

src/vs/workbench/api/browser/mainThreadTerminalService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { StopWatch } from 'vs/base/common/stopwatch';
88
import { URI } from 'vs/base/common/uri';
99
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1010
import { ILogService } from 'vs/platform/log/common/log';
11-
import { IShellLaunchConfig, ITerminalDimensions } from 'vs/platform/terminal/common/terminal';
11+
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensions } from 'vs/platform/terminal/common/terminal';
1212
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
13-
import { ExtHostContext, ExtHostTerminalServiceShape, IExtHostContext, IShellLaunchConfigDto, ITerminalDimensionsDto, MainContext, MainThreadTerminalServiceShape, TerminalIdentifier, TerminalLaunchConfig } from 'vs/workbench/api/common/extHost.protocol';
13+
import { ExtHostContext, ExtHostTerminalServiceShape, IExtHostContext, ITerminalDimensionsDto, MainContext, MainThreadTerminalServiceShape, TerminalIdentifier, TerminalLaunchConfig } from 'vs/workbench/api/common/extHost.protocol';
1414
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
1515
import { ITerminalExternalLinkProvider, ITerminalInstance, ITerminalInstanceService, ITerminalLink, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal';
1616
import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ import { InternalTestItem, ITestState, RunTestForProviderRequest, RunTestsReques
6060
import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService';
6161
import { WorkspaceTrustRequestOptions, WorkspaceTrustStateChangeEvent } from 'vs/platform/workspace/common/workspaceTrust';
6262
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
63-
import { IShellLaunchConfig, ITerminalDimensions, ITerminalLaunchError } from 'vs/platform/terminal/common/terminal';
63+
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensions, ITerminalEnvironment, ITerminalLaunchError } from 'vs/platform/terminal/common/terminal';
6464
import { ITerminalProfile } from 'vs/workbench/contrib/terminal/common/terminal';
6565

6666
export interface IEnvironment {
@@ -454,7 +454,7 @@ export interface TerminalLaunchConfig {
454454
shellPath?: string;
455455
shellArgs?: string[] | string;
456456
cwd?: string | UriComponents;
457-
env?: { [key: string]: string | null; };
457+
env?: ITerminalEnvironment;
458458
waitOnExit?: boolean;
459459
strictEnv?: boolean;
460460
hideFromUser?: boolean;
@@ -1609,15 +1609,6 @@ export interface ExtHostTelemetryShape {
16091609
$onDidChangeTelemetryEnabled(enabled: boolean): void;
16101610
}
16111611

1612-
export interface IShellLaunchConfigDto {
1613-
name?: string;
1614-
executable?: string;
1615-
args?: string[] | string;
1616-
cwd?: string | UriComponents;
1617-
env?: { [key: string]: string | null; };
1618-
hideFromUser?: boolean;
1619-
}
1620-
16211612
export interface IShellAndArgsDto {
16221613
shell: string;
16231614
args: string[] | string | undefined;

src/vs/workbench/api/common/extHostTerminalService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import type * as vscode from 'vscode';
77
import { Event, Emitter } from 'vs/base/common/event';
8-
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IShellLaunchConfigDto, IShellAndArgsDto, ITerminalDimensionsDto, ITerminalLinkDto, TerminalIdentifier } from 'vs/workbench/api/common/extHost.protocol';
8+
import { ExtHostTerminalServiceShape, MainContext, MainThreadTerminalServiceShape, IShellAndArgsDto, ITerminalDimensionsDto, ITerminalLinkDto, TerminalIdentifier } from 'vs/workbench/api/common/extHost.protocol';
99
import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration';
1010
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
1111
import { URI } from 'vs/base/common/uri';
@@ -19,7 +19,7 @@ import { serializeEnvironmentVariableCollection } from 'vs/workbench/contrib/ter
1919
import { CancellationTokenSource } from 'vs/base/common/cancellation';
2020
import { generateUuid } from 'vs/base/common/uuid';
2121
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
22-
import { ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, TerminalShellType } from 'vs/platform/terminal/common/terminal';
22+
import { IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, TerminalShellType } from 'vs/platform/terminal/common/terminal';
2323
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
2424
import { ITerminalProfile } from 'vs/workbench/contrib/terminal/common/terminal';
2525

@@ -117,7 +117,7 @@ export class ExtHostTerminal {
117117
shellPath?: string,
118118
shellArgs?: string[] | string,
119119
cwd?: string | URI,
120-
env?: { [key: string]: string | null },
120+
env?: ITerminalEnvironment,
121121
waitOnExit?: boolean,
122122
strictEnv?: boolean,
123123
hideFromUser?: boolean,

src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
1212
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import { ILogService } from 'vs/platform/log/common/log';
1414
import { INotificationHandle, INotificationService, IPromptChoice, Severity } from 'vs/platform/notification/common/notification';
15-
import { IShellLaunchConfig, ITerminalChildProcess, ITerminalsLayoutInfo, ITerminalsLayoutInfoById } from 'vs/platform/terminal/common/terminal';
15+
import { IShellLaunchConfig, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalsLayoutInfo, ITerminalsLayoutInfoById } from 'vs/platform/terminal/common/terminal';
1616
import { RemotePty } from 'vs/workbench/contrib/terminal/browser/remotePty';
1717
import { IRemoteTerminalService, ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
18-
import { IShellLaunchConfigDto, RemoteTerminalChannelClient, REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
18+
import { RemoteTerminalChannelClient, REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
1919
import { IRemoteTerminalAttachTarget, ITerminalConfigHelper } from 'vs/workbench/contrib/terminal/common/terminal';
2020
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
2121

src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,12 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
1818
import { Schemas } from 'vs/base/common/network';
1919
import { ILabelService } from 'vs/platform/label/common/label';
2020
import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
21-
import { IProcessDataEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalShellType } from 'vs/platform/terminal/common/terminal';
21+
import { IProcessDataEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalShellType } from 'vs/platform/terminal/common/terminal';
2222
import { ITerminalConfiguration, TERMINAL_CONFIG_SECTION } from 'vs/workbench/contrib/terminal/common/terminal';
2323
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
2424

2525
export const REMOTE_TERMINAL_CHANNEL_NAME = 'remoteterminal';
2626

27-
export interface IShellLaunchConfigDto {
28-
name?: string;
29-
executable?: string;
30-
args?: string[] | string;
31-
cwd?: string | UriComponents;
32-
env?: { [key: string]: string | null; };
33-
hideFromUser?: boolean;
34-
}
35-
3627
export interface ISingleTerminalConfiguration<T> {
3728
userValue: T | undefined;
3829
value: T | undefined;

src/vs/workbench/contrib/terminal/common/terminalEnvironment.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ export function mergeEnvironments(parent: platform.IProcessEnvironment, other: I
3333
}
3434
}
3535
const value = other[configKey];
36-
_mergeEnvironmentValue(parent, actualKey, value);
36+
if (value !== undefined) {
37+
_mergeEnvironmentValue(parent, actualKey, value);
38+
}
3739
}
3840
} else {
3941
Object.keys(other).forEach((key) => {
4042
const value = other[key];
41-
_mergeEnvironmentValue(parent, key, value);
43+
if (value !== undefined) {
44+
_mergeEnvironmentValue(parent, key, value);
45+
}
4246
});
4347
}
4448
}

0 commit comments

Comments
 (0)