Skip to content

Commit

Permalink
#95209 Move to final API
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Oct 27, 2020
1 parent 7beee04 commit 325cb4a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
7 changes: 6 additions & 1 deletion src/vs/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5647,7 +5647,12 @@ declare module 'vscode' {
* A memento object that stores state independent
* of the current opened [workspace](#workspace.workspaceFolders).
*/
readonly globalState: Memento;
readonly globalState: Memento & {
/**
* Set the keys whose values should be synced across devices when extensions synchronization is enabled.
*/
setKeysForSync(keys: string[]): void;
};

/**
* The uri of the directory containing the extension.
Expand Down
14 changes: 0 additions & 14 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2169,18 +2169,4 @@ declare module 'vscode' {

}
//#endregion

//#region Syncing Extension's Global State https://github.com/microsoft/vscode/issues/95209 @sandy081
export interface ExtensionContext {

readonly syncedGlobalState: Memento & {
/**
* List of keys whose values should be synced across devices when extensions synchronization is enabled .
* Set synced keys to an empty array to unset the synced state.
*/
syncedKeys: ReadonlyArray<string>;
};

}
//#endregion
}
1 change: 0 additions & 1 deletion src/vs/workbench/api/common/extHostExtensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
const that = this;
return Object.freeze<vscode.ExtensionContext>({
globalState,
get syncedGlobalState() { checkProposedApiEnabled(extensionDescription); return globalState; },
workspaceState,
subscriptions: [],
get extensionUri() { return extensionDescription.extensionLocation; },
Expand Down
9 changes: 2 additions & 7 deletions src/vs/workbench/api/common/extHostMemento.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import type * as vscode from 'vscode';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ExtHostStorage } from 'vs/workbench/api/common/extHostStorage';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';

export class ExtensionMemento implements vscode.Memento {

Expand Down Expand Up @@ -64,12 +63,8 @@ export class ExtensionGlobalMemento extends ExtensionMemento {

private readonly _extension: IExtensionDescription;

private _syncedKeys: string[] = [];
get syncedKeys(): ReadonlyArray<string> { return Object.freeze(this._syncedKeys); }
set syncedKeys(syncKeys: ReadonlyArray<string>) {
checkProposedApiEnabled(this._extension);
this._syncedKeys = [...syncKeys];
this._storage.registerExtensionStorageKeysToSync({ id: this._id, version: this._extension.version }, this._syncedKeys);
setKeysForSync(keys: string[]): void {
this._storage.registerExtensionStorageKeysToSync({ id: this._id, version: this._extension.version }, keys);
}

constructor(extensionDescription: IExtensionDescription, storage: ExtHostStorage) {
Expand Down

0 comments on commit 325cb4a

Please # to comment.