forked from golang/vscode-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stateUtils.ts
45 lines (37 loc) · 1.15 KB
/
stateUtils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------*/
import vscode = require('vscode');
let globalState: vscode.Memento;
let workspaceState: vscode.Memento;
export function getFromGlobalState(key: string, defaultValue?: any) {
if (!globalState) {
return defaultValue;
}
return globalState.get(key, defaultValue);
}
export function updateGlobalState(key: string, value: any) {
if (!globalState) {
return;
}
return globalState.update(key, value);
}
export function setGlobalState(state: vscode.Memento) {
globalState = state;
}
export function getFromWorkspaceState(key: string, defaultValue?: any) {
if (!workspaceState) {
return defaultValue;
}
return workspaceState.get(key, defaultValue);
}
export function updateWorkspaceState(key: string, value: any) {
if (!workspaceState) {
return;
}
return workspaceState.update(key, value);
}
export function setWorkspaceState(state: vscode.Memento) {
workspaceState = state;
}