aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/color_theme.ts
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-05 20:29:50 +0000
committerGitHub <[email protected]>2020-02-05 20:29:50 +0000
commit2471b6bc3a318d7303d0556c85940090b6cf6d7a (patch)
tree07df61a25b0735d96f78bbd754bc7c16b9361926 /editors/code/src/color_theme.ts
parent8d0f7da2f5f2ae1dc5711005f08fde0007da165b (diff)
parent49a681404860e98855d8698e94dc1208e07daff4 (diff)
Merge #3015
3015: vscode: yet another refactor commit r=matklad a=Veetaha It compiles, it runs in dev extension host, It bundles, it runs when bundled and installed. Removed 5 lines of code as you like less code, especially TypeScript code) Co-authored-by: Veetaha <[email protected]>
Diffstat (limited to 'editors/code/src/color_theme.ts')
-rw-r--r--editors/code/src/color_theme.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts
index 7e10c7f79..a6957a76e 100644
--- a/editors/code/src/color_theme.ts
+++ b/editors/code/src/color_theme.ts
@@ -33,6 +33,7 @@ export class ColorTheme {
33 : typeof rule.scope === 'string' 33 : typeof rule.scope === 'string'
34 ? [rule.scope] 34 ? [rule.scope]
35 : rule.scope; 35 : rule.scope;
36
36 for (const scope of scopes) { 37 for (const scope of scopes) {
37 res.rules.set(scope, rule.settings); 38 res.rules.set(scope, rule.settings);
38 } 39 }
@@ -69,13 +70,13 @@ function loadThemeNamed(themeName: string): ColorTheme {
69 ); 70 );
70 } 71 }
71 72
72 const themePaths = vscode.extensions.all 73 const themePaths: string[] = vscode.extensions.all
73 .filter(isTheme) 74 .filter(isTheme)
74 .flatMap(ext => { 75 .flatMap(
75 return ext.packageJSON.contributes.themes 76 ext => ext.packageJSON.contributes.themes
76 .filter((it: any) => (it.id || it.label) === themeName) 77 .filter((it: any) => (it.id || it.label) === themeName)
77 .map((it: any) => path.join(ext.extensionPath, it.path)); 78 .map((it: any) => path.join(ext.extensionPath, it.path))
78 }); 79 );
79 80
80 const res = new ColorTheme(); 81 const res = new ColorTheme();
81 for (const themePath of themePaths) { 82 for (const themePath of themePaths) {
@@ -96,13 +97,12 @@ function loadThemeFile(themePath: string): ColorTheme {
96 return new ColorTheme(); 97 return new ColorTheme();
97 } 98 }
98 const obj = jsonc.parse(text); 99 const obj = jsonc.parse(text);
99 const tokenColors = obj?.tokenColors ?? []; 100 const tokenColors: TextMateRule[] = obj?.tokenColors ?? [];
100 const res = ColorTheme.fromRules(tokenColors); 101 const res = ColorTheme.fromRules(tokenColors);
101 102
102 for (const include in obj?.include ?? []) { 103 for (const include of obj?.include ?? []) {
103 const includePath = path.join(path.dirname(themePath), include); 104 const includePath = path.join(path.dirname(themePath), include);
104 const tmp = loadThemeFile(includePath); 105 res.mergeFrom(loadThemeFile(includePath));
105 res.mergeFrom(tmp);
106 } 106 }
107 107
108 return res; 108 return res;