forked from JohnstonCode/svn-scm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.ts
54 lines (42 loc) · 1.25 KB
/
configuration.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
46
47
48
49
50
51
52
53
54
"use strict";
import {
ConfigurationChangeEvent,
ConfigurationTarget,
Event,
EventEmitter,
workspace,
WorkspaceConfiguration
} from "vscode";
const SVN = "svn";
class Configuration {
private configuration: WorkspaceConfiguration;
private _onDidChange = new EventEmitter<ConfigurationChangeEvent>();
get onDidChange(): Event<ConfigurationChangeEvent> {
return this._onDidChange.event;
}
constructor() {
this.configuration = workspace.getConfiguration(SVN);
workspace.onDidChangeConfiguration(this.onConfigurationChanged, this);
}
private onConfigurationChanged(event: ConfigurationChangeEvent) {
if (!event.affectsConfiguration(SVN)) {
return;
}
this.configuration = workspace.getConfiguration(SVN);
this._onDidChange.fire(event);
}
public get<T>(section: string, defaultValue?: T): T {
return this.configuration.get<T>(section, defaultValue!);
}
public update(
section: string,
value: any,
configurationTarget?: ConfigurationTarget | boolean
): Thenable<void> {
return this.configuration.update(section, value, configurationTarget);
}
public inspect(section: string) {
return this.configuration.inspect(section);
}
}
export const configuration = new Configuration();