forked from LeetCode-OpenSource/vscode-leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingUtils.ts
68 lines (57 loc) · 2.26 KB
/
settingUtils.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) jdneo. All rights reserved.
// Licensed under the MIT license.
import { workspace, WorkspaceConfiguration } from "vscode";
import { DescriptionConfiguration } from "../shared";
export function getWorkspaceConfiguration(): WorkspaceConfiguration {
return workspace.getConfiguration("leetcode");
}
export function shouldHideSolvedProblem(): boolean {
return getWorkspaceConfiguration().get<boolean>("hideSolved", false);
}
export function getWorkspaceFolder(): string {
return getWorkspaceConfiguration().get<string>("workspaceFolder", "");
}
export function getEditorShortcuts(): string[] {
return getWorkspaceConfiguration().get<string[]>("editor.shortcuts", ["submit", "test"]);
}
export function hasStarShortcut(): boolean {
const shortcuts: string[] = getWorkspaceConfiguration().get<string[]>("editor.shortcuts", ["submit", "test"]);
return shortcuts.indexOf("star") >= 0;
}
export function shouldUseEndpointTranslation(): boolean {
return getWorkspaceConfiguration().get<boolean>("useEndpointTranslation", true);
}
export function getDescriptionConfiguration(): IDescriptionConfiguration {
const setting: string = getWorkspaceConfiguration().get<string>("showDescription", DescriptionConfiguration.InWebView);
const config: IDescriptionConfiguration = {
showInComment: false,
showInWebview: true,
};
switch (setting) {
case DescriptionConfiguration.Both:
config.showInComment = true;
config.showInWebview = true;
break;
case DescriptionConfiguration.None:
config.showInComment = false;
config.showInWebview = false;
break;
case DescriptionConfiguration.InFileComment:
config.showInComment = true;
config.showInWebview = false;
break;
case DescriptionConfiguration.InWebView:
config.showInComment = false;
config.showInWebview = true;
break;
}
// To be compatible with the deprecated setting:
if (getWorkspaceConfiguration().get<boolean>("showCommentDescription")) {
config.showInComment = true;
}
return config;
}
export interface IDescriptionConfiguration {
showInComment: boolean;
showInWebview: boolean;
}