diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index cd6139652b3..9e749114312 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -1147,4 +1147,18 @@ declare module 'vscode' { } //#endregion + //#region Extension Context + export interface ExtensionContext { + + /** + * An absolute file path in which the extension can store gloabal state. + * The directory might not exist on disk and creation is + * up to the extension. However, the parent directory is guaranteed to be existent. + * + * Use [`globalState`](#ExtensionContext.globalState) to store key value data. + */ + globalStoragePath: string; + + } + //#endregion } diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 87c45e90ebd..6029a4eeedc 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -50,6 +50,7 @@ export interface IEnvironment { appSettingsHome: URI; extensionDevelopmentLocationURI: URI; extensionTestsPath: string; + globalStorageHome: string; } export interface IWorkspaceData { diff --git a/src/vs/workbench/api/node/extHostExtensionActivator.ts b/src/vs/workbench/api/node/extHostExtensionActivator.ts index 48475d388f8..e875258fcb7 100644 --- a/src/vs/workbench/api/node/extHostExtensionActivator.ts +++ b/src/vs/workbench/api/node/extHostExtensionActivator.ts @@ -23,6 +23,7 @@ export interface IExtensionContext { globalState: IExtensionMemento; extensionPath: string; storagePath: string; + globalStoragePath: string; asAbsolutePath(relativePath: string): string; readonly logPath: string; } diff --git a/src/vs/workbench/api/node/extHostExtensionService.ts b/src/vs/workbench/api/node/extHostExtensionService.ts index b3783a67413..45b80a26efd 100644 --- a/src/vs/workbench/api/node/extHostExtensionService.ts +++ b/src/vs/workbench/api/node/extHostExtensionService.ts @@ -91,13 +91,17 @@ class ExtensionStoragePath { return this._ready; } - value(extension: IExtensionDescription): string { + workspaceValue(extension: IExtensionDescription): string { if (this._value) { return join(this._value, extension.id); } return undefined; } + globalValue(extension: IExtensionDescription): string { + return join(this._environment.globalStorageHome, extension.id); + } + private async _getOrCreateWorkspaceStoragePath(): Promise { if (!this._workspace) { return Promise.resolve(undefined); @@ -383,7 +387,8 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { workspaceState, subscriptions: [], get extensionPath() { return extensionDescription.extensionLocation.fsPath; }, - storagePath: this._storagePath.value(extensionDescription), + storagePath: this._storagePath.workspaceValue(extensionDescription), + globalStoragePath: this._storagePath.globalValue(extensionDescription), asAbsolutePath: (relativePath: string) => { return join(extensionDescription.extensionLocation.fsPath, relativePath); }, logPath: that._extHostLogService.getLogDirectory(extensionDescription.id) }); diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts b/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts index c62c562a2ca..28a41e9029c 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts @@ -424,7 +424,8 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter { appRoot: this._environmentService.appRoot ? URI.file(this._environmentService.appRoot) : void 0, appSettingsHome: this._environmentService.appSettingsHome ? URI.file(this._environmentService.appSettingsHome) : void 0, extensionDevelopmentLocationURI: this._environmentService.extensionDevelopmentLocationURI, - extensionTestsPath: this._environmentService.extensionTestsPath + extensionTestsPath: this._environmentService.extensionTestsPath, + globalStorageHome: this._environmentService.globalStorageHome }, workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : { configuration: workspace.configuration,