Reputation: 9796
I followed the document of when clause context and added a custom when clause context.
I set a boolean context:
let start = vscode.commands.registerCommand('myExt.start', () => {
vscode.commands.executeCommand('setContext', 'myExt.activated', true);
});
But after the VSCode restarts, even if myExt.activated
is true
. VSCode forget it...
"explorer/context": [
{
"command": "myExt.filter",
"when": "myExt.activated"
}
]
Not showing after VSCode restarts even if myExt.activated
was true
in the last time...
Also, when debugging the context with the Developer: Inspect Context Keys
command, the myExt.activated
is not there.
Is there any way to persist when-clause context between VSCode restarts?
Upvotes: 2
Views: 946
Reputation: 9796
Since the answers appear in the comments (by @rioV8 and @Mark) I will summarize them here:
For storing persist data there are globalState
and workspaceState
(from the ExtensionContext
).
For storing persist context we have to use globalState
or workspaceState
to store the state and register to *
or onStartupFinished
activation events and immediately call setContext
with the state for the persist storage.
Upvotes: 2