Skip to content

Commit 321c275

Browse files
author
Benjamin Pasero
committed
cleanup environment service
1 parent 915d37d commit 321c275

8 files changed

Lines changed: 78 additions & 67 deletions

File tree

src/vs/workbench/contrib/update/browser/update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class ProductContribution implements IWorkbenchContribution {
134134

135135
// was there an update? if so, open release notes
136136
const releaseNotesUrl = productService.releaseNotesUrl;
137-
if (shouldShowReleaseNotes && !environmentService.skipReleaseNotes && releaseNotesUrl && lastVersion && productService.version !== lastVersion) {
137+
if (shouldShowReleaseNotes && !environmentService.args['skip-release-notes'] && releaseNotesUrl && lastVersion && productService.version !== lastVersion) {
138138
showReleaseNotes(instantiationService, productService.version)
139139
.then(undefined, () => {
140140
notificationService.prompt(

src/vs/workbench/services/environment/browser/environmentService.ts

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { IProcessEnvironment } from 'vs/base/common/platform';
99
import { joinPath } from 'vs/base/common/resources';
1010
import { URI } from 'vs/base/common/uri';
1111
import { generateUuid } from 'vs/base/common/uuid';
12-
import { BACKUPS, IDebugParams, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
12+
import { BACKUPS, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
1313
import { LogLevel } from 'vs/platform/log/common/log';
1414
import { IPath, IPathsToWaitFor, IWindowConfiguration } from 'vs/platform/windows/common/windows';
1515
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
@@ -23,7 +23,7 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
2323

2424
constructor(private readonly options: IBrowserWorkbenchEnvironmentConstructionOptions, private readonly environment: IWorkbenchEnvironmentService) { }
2525

26-
//#region PROPERLY CONFIGURED
26+
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
2727

2828
@memoize
2929
get sessionId(): string { return generateUuid(); }
@@ -37,27 +37,32 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
3737
@memoize
3838
get backupWorkspaceResource(): URI { return joinPath(this.environment.backupHome, this.options.workspaceId); }
3939

40+
// TODO@rachel TODO@sbatten fix me, should be stable between sessions
41+
@memoize
42+
get machineId(): string { return generateUuid(); }
43+
44+
// Currently unsupported in web
45+
get filesToOpenOrCreate(): IPath[] | undefined { return undefined; }
46+
get filesToDiff(): IPath[] | undefined { return undefined; }
47+
4048
//#endregion
4149

4250

43-
//#region TODO@ben TO BE DONE
51+
//#region TODO MOVE TO NODE LAYER
4452

4553
_!: any[];
4654

47-
readonly machineId = generateUuid();
4855
windowId!: number;
49-
logLevel!: LogLevel;
50-
5156
mainPid!: number;
5257

58+
logLevel!: LogLevel;
59+
5360
appRoot!: string;
5461
execPath!: string;
55-
isInitialStartup?: boolean;
56-
57-
userEnv!: IProcessEnvironment;
62+
backupPath?: string;
5863
nodeCachedDataDir?: string;
5964

60-
backupPath?: string;
65+
userEnv!: IProcessEnvironment;
6166

6267
workspace?: IWorkspaceIdentifier;
6368
folderUri?: ISingleFolderWorkspaceIdentifier;
@@ -69,10 +74,9 @@ export class BrowserWindowConfiguration implements IWindowConfiguration {
6974
accessibilitySupport?: boolean;
7075
partsSplashPath?: string;
7176

77+
isInitialStartup?: boolean;
7278
perfEntries!: ExportData;
7379

74-
filesToOpenOrCreate?: IPath[];
75-
filesToDiff?: IPath[];
7680
filesToWait?: IPathsToWaitFor;
7781

7882
//#endregion
@@ -99,7 +103,7 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
99103

100104
_serviceBrand: undefined;
101105

102-
//#region PROPERLY CONFIGURED
106+
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
103107

104108
@memoize
105109
get isBuilt(): boolean { return !!product.commit; }
@@ -175,10 +179,17 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
175179
return this.webviewExternalEndpoint.replace('{{uuid}}', '*');
176180
}
177181

182+
// Currently not configurable in web
183+
get disableExtensions() { return false; }
184+
get extensionsPath(): string | undefined { return undefined; }
185+
get verbose(): boolean { return false; }
186+
get disableUpdates(): boolean { return false; }
187+
get logExtensionHostCommunication(): boolean { return false; }
188+
178189
//#endregion
179190

180191

181-
//#region TODO@ben TO BE DONE
192+
//#region TODO MOVE TO NODE LAYER
182193

183194
private _configuration: IWindowConfiguration | undefined = undefined;
184195
get configuration(): IWindowConfiguration {
@@ -189,47 +200,53 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
189200
return this._configuration;
190201
}
191202

192-
readonly args = { _: [] };
193-
readonly appRoot = '/web/';
194-
195-
argvResource!: URI;
196-
197-
extensionTestsLocationURI?: URI;
198-
199-
execPath!: string;
200-
cliPath!: string;
201-
userHome!: string;
202-
userDataPath!: string;
203-
appSettingsHome!: URI;
204-
205-
machineSettingsHome!: URI;
206-
machineSettingsResource!: URI;
207-
globalStorageHome!: string;
208-
workspaceStorageHome!: string;
209-
backupWorkspacesPath!: string;
210-
211-
disableExtensions!: boolean | string[];
212-
builtinExtensionsPath!: string;
213-
extensionsPath?: string;
214-
debugSearch!: IDebugParams;
215-
logExtensionHostCommunication!: boolean;
203+
args = { _: [] };
216204

217205
wait!: boolean;
218206
status!: boolean;
219207
log?: string;
220208

221-
verbose!: boolean;
222-
skipReleaseNotes!: boolean;
223209
mainIPCHandle!: string;
224210
sharedIPCHandle!: string;
211+
225212
nodeCachedDataDir?: string;
226-
installSourcePath!: string;
227-
disableUpdates!: boolean;
213+
214+
argvResource!: URI;
215+
228216
disableCrashReporter!: boolean;
217+
229218
driverHandle?: string;
230219
driverVerbose!: boolean;
220+
221+
installSourcePath!: string;
222+
223+
builtinExtensionsPath!: string;
224+
225+
globalStorageHome!: string;
226+
workspaceStorageHome!: string;
227+
228+
backupWorkspacesPath!: string;
229+
230+
machineSettingsHome!: URI;
231+
machineSettingsResource!: URI;
232+
233+
userDataPath!: string;
234+
appRoot!: string;
235+
appSettingsHome!: URI;
236+
execPath!: string;
237+
cliPath!: string;
238+
239+
//#endregion
240+
241+
242+
//#region TODO ENABLE IN WEB
243+
244+
extensionTestsLocationURI?: URI;
245+
231246
galleryMachineIdResource?: URI;
232247

248+
userHome!: string;
249+
233250
//#endregion
234251

235252
constructor(readonly options: IBrowserWorkbenchEnvironmentConstructionOptions) { }

src/vs/workbench/services/environment/common/environmentService.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
77
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
8-
import { IEnvironmentService, IDebugParams } from 'vs/platform/environment/common/environment';
8+
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
99
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
1010
import { URI } from 'vs/base/common/uri';
1111

@@ -22,12 +22,7 @@ export interface IWorkbenchEnvironmentService extends IEnvironmentService {
2222
readonly logFile: URI;
2323
readonly logExtensionHostCommunication: boolean;
2424

25-
readonly debugSearch: IDebugParams;
26-
2725
readonly webviewExternalEndpoint: string;
2826
readonly webviewResourceRoot: string;
2927
readonly webviewCspSource: string;
30-
31-
readonly skipReleaseNotes: boolean | undefined;
32-
3328
}

src/vs/workbench/services/environment/electron-browser/environmentService.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { EnvironmentService, parseSearchPort } from 'vs/platform/environment/node/environmentService';
6+
import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
77
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
88
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
99
import { memoize } from 'vs/base/common/decorators';
1010
import { URI } from 'vs/base/common/uri';
1111
import { Schemas } from 'vs/base/common/network';
1212
import { toBackupWorkspaceResource } from 'vs/workbench/services/backup/electron-browser/backup';
1313
import { join } from 'vs/base/common/path';
14-
import { IDebugParams } from 'vs/platform/environment/common/environment';
1514
import product from 'vs/platform/product/common/product';
1615

1716
export class NativeWorkbenchEnvironmentService extends EnvironmentService implements IWorkbenchEnvironmentService {
@@ -31,9 +30,6 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem
3130
@memoize
3231
get webviewCspSource(): string { return 'vscode-resource:'; }
3332

34-
@memoize
35-
get skipReleaseNotes(): boolean { return !!this.args['skip-release-notes']; }
36-
3733
@memoize
3834
get userRoamingDataHome(): URI { return this.appSettingsHome.with({ scheme: Schemas.userData }); }
3935

@@ -43,9 +39,6 @@ export class NativeWorkbenchEnvironmentService extends EnvironmentService implem
4339
@memoize
4440
get logExtensionHostCommunication(): boolean { return !!this.args.logExtensionHostCommunication; }
4541

46-
@memoize
47-
get debugSearch(): IDebugParams { return parseSearchPort(this.args, this.isBuilt); }
48-
4942
constructor(
5043
readonly configuration: IWindowConfiguration,
5144
execPath: string,

src/vs/workbench/services/search/node/searchService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
2626
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
2727
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
2828
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
29+
import { parseSearchPort } from 'vs/platform/environment/node/environmentService';
2930

3031
export class LocalSearchService extends SearchService {
3132
constructor(
@@ -42,7 +43,7 @@ export class LocalSearchService extends SearchService {
4243
super(modelService, untitledEditorService, editorService, telemetryService, logService, extensionService, fileService);
4344

4445

45-
this.diskSearch = instantiationService.createInstance(DiskSearch, !environmentService.isBuilt || environmentService.verbose, environmentService.debugSearch);
46+
this.diskSearch = instantiationService.createInstance(DiskSearch, !environmentService.isBuilt || environmentService.verbose, parseSearchPort(environmentService.args, environmentService.isBuilt));
4647
}
4748
}
4849

src/vs/workbench/services/telemetry/browser/telemetryService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ export class TelemetryService extends Disposable implements ITelemetryService {
5252
) {
5353
super();
5454

55-
if (!environmentService.args['disable-telemetry'] && !!productService.enableTelemetry) {
55+
if (!!productService.enableTelemetry) {
5656
const config: ITelemetryServiceConfig = {
5757
appender: combinedAppender(new WebTelemetryAppender(logService, remoteAgentService), new LogAppender(logService)),
58-
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.configuration.machineId, environmentService.configuration.remoteAuthority),
59-
piiPaths: [environmentService.appRoot]
58+
commonProperties: resolveWorkbenchCommonProperties(storageService, productService.commit, productService.version, environmentService.configuration.machineId, environmentService.configuration.remoteAuthority)
6059
};
6160

6261
this.impl = this._register(new BaseTelemetryService(config, configurationService));

src/vs/workbench/services/textfile/browser/textFileService.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,16 +566,11 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
566566
}
567567

568568
async confirmSave(resources?: URI[]): Promise<ConfirmResult> {
569-
if (this.environmentService.isExtensionDevelopment) {
570-
if (!this.environmentService.args['extension-development-confirm-save']) {
571-
return ConfirmResult.DONT_SAVE; // no veto when we are in extension dev mode because we cannot assume we run interactive (e.g. tests)
572-
}
573-
}
574-
575569
const resourcesToConfirm = this.getDirty(resources);
576570
if (resourcesToConfirm.length === 0) {
577571
return ConfirmResult.DONT_SAVE;
578572
}
573+
579574
return promptSave(this.dialogService, resourcesToConfirm);
580575
}
581576

src/vs/workbench/services/textfile/electron-browser/nativeTextFileService.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { IHistoryService } from 'vs/workbench/services/history/common/history';
4141
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
4242
import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
4343
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
44+
import { ConfirmResult } from 'vs/workbench/common/editor';
4445

4546
export class NativeTextFileService extends AbstractTextFileService {
4647

@@ -297,6 +298,16 @@ export class NativeTextFileService extends AbstractTextFileService {
297298
protected getWindowCount(): Promise<number> {
298299
return this.electronService.getWindowCount();
299300
}
301+
302+
async confirmSave(resources?: URI[]): Promise<ConfirmResult> {
303+
if (this.environmentService.isExtensionDevelopment) {
304+
if (!this.environmentService.args['extension-development-confirm-save']) { //
305+
return ConfirmResult.DONT_SAVE; // no veto when we are in extension dev mode because we cannot assume we run interactive (e.g. tests)
306+
}
307+
}
308+
309+
return super.confirmSave(resources);
310+
}
300311
}
301312

302313
export interface IEncodingOverride {

0 commit comments

Comments
 (0)