Skip to content

Commit 1b333be

Browse files
plugin: stub setKeysForSync
The commit stubs the method `setKeysForSync` as it is currently not supported by the framework and likely uses vscode online services to store data across machines. Signed-off-by: vince-fugnitto <[email protected]>
1 parent 4ba87c8 commit 1b333be

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

packages/plugin-ext/src/plugin/plugin-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import * as theia from '@theia/plugin';
3333
import { join } from './path';
3434
import { EnvExtImpl } from './env';
3535
import { PreferenceRegistryExtImpl } from './preference-registry';
36-
import { Memento, KeyValueStorageProxy } from './plugin-storage';
36+
import { Memento, KeyValueStorageProxy, GlobalState } from './plugin-storage';
3737
import { ExtPluginApi } from '../common/plugin-ext-api-contribution';
3838
import { RPCProtocol } from '../common/rpc-protocol';
3939
import { Emitter } from '@theia/core/lib/common/event';
@@ -372,7 +372,7 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
372372
const pluginContext: theia.PluginContext = {
373373
extensionPath: plugin.pluginFolder,
374374
extensionUri: Uri.file(plugin.pluginFolder),
375-
globalState: new Memento(plugin.model.id, true, this.storageProxy),
375+
globalState: new GlobalState(plugin.model.id, true, this.storageProxy),
376376
workspaceState: new Memento(plugin.model.id, false, this.storageProxy),
377377
subscriptions: subscriptions,
378378
asAbsolutePath: asAbsolutePath,

packages/plugin-ext/src/plugin/plugin-storage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export class Memento implements theia.Memento {
6060
}
6161
}
6262

63+
export class GlobalState extends Memento {
64+
65+
/** @todo: API is not yet implemented. */
66+
setKeysForSync(keys: readonly string[]): void { }
67+
}
68+
6369
/**
6470
* Singleton.
6571
* Is used to proxy storage requests to main side.

packages/plugin/src/theia.d.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3064,7 +3064,22 @@ declare module '@theia/plugin' {
30643064
* A memento object that stores state independent
30653065
* of the current opened [workspace](#workspace.workspaceFolders).
30663066
*/
3067-
globalState: Memento;
3067+
globalState: Memento & {
3068+
/**
3069+
* Set the keys whose values should be synchronized across devices when synchronizing user-data
3070+
* like configuration, extensions, and mementos.
3071+
*
3072+
* Note that this function defines the whole set of keys whose values are synchronized:
3073+
* - calling it with an empty array stops synchronization for this memento
3074+
* - calling it with a non-empty array replaces all keys whose values are synchronized
3075+
*
3076+
* For any given set of keys this function needs to be called only once but there is no harm in
3077+
* repeatedly calling it.
3078+
*
3079+
* @param keys The set of keys whose values are synced.
3080+
*/
3081+
setKeysForSync(keys: readonly string[]): void;
3082+
};
30683083

30693084
/**
30703085
* A storage utility for secrets.

0 commit comments

Comments
 (0)