aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/color_theme.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/color_theme.ts')
-rw-r--r--editors/code/src/color_theme.ts28
1 files changed, 14 insertions, 14 deletions
diff --git a/editors/code/src/color_theme.ts b/editors/code/src/color_theme.ts
index 1df7eba7a..cbad47f35 100644
--- a/editors/code/src/color_theme.ts
+++ b/editors/code/src/color_theme.ts
@@ -32,29 +32,29 @@ export class ColorTheme {
32 ? [rule.scope] 32 ? [rule.scope]
33 : rule.scope; 33 : rule.scope;
34 for (const scope of scopes) { 34 for (const scope of scopes) {
35 res.rules.set(scope, rule.settings) 35 res.rules.set(scope, rule.settings);
36 } 36 }
37 } 37 }
38 return res 38 return res;
39 } 39 }
40 40
41 lookup(scopes: string[]): TextMateRuleSettings { 41 lookup(scopes: string[]): TextMateRuleSettings {
42 let res: TextMateRuleSettings = {} 42 let res: TextMateRuleSettings = {};
43 for (const scope of scopes) { 43 for (const scope of scopes) {
44 this.rules.forEach((value, key) => { 44 this.rules.forEach((value, key) => {
45 if (scope.startsWith(key)) { 45 if (scope.startsWith(key)) {
46 res = mergeRuleSettings(res, value) 46 res = mergeRuleSettings(res, value);
47 } 47 }
48 }) 48 });
49 } 49 }
50 return res 50 return res;
51 } 51 }
52 52
53 mergeFrom(other: ColorTheme) { 53 mergeFrom(other: ColorTheme) {
54 other.rules.forEach((value, key) => { 54 other.rules.forEach((value, key) => {
55 const merged = mergeRuleSettings(this.rules.get(key), value) 55 const merged = mergeRuleSettings(this.rules.get(key), value);
56 this.rules.set(key, merged) 56 this.rules.set(key, merged);
57 }) 57 });
58 } 58 }
59} 59}
60 60
@@ -73,15 +73,15 @@ function loadThemeNamed(themeName: string): ColorTheme {
73 return ext.packageJSON.contributes.themes 73 return ext.packageJSON.contributes.themes
74 .filter((it: any) => (it.id || it.label) === themeName) 74 .filter((it: any) => (it.id || it.label) === themeName)
75 .map((it: any) => path.join(ext.extensionPath, it.path)); 75 .map((it: any) => path.join(ext.extensionPath, it.path));
76 }) 76 });
77 77
78 const res = new ColorTheme(); 78 const res = new ColorTheme();
79 for (const themePath of themePaths) { 79 for (const themePath of themePaths) {
80 res.mergeFrom(loadThemeFile(themePath)) 80 res.mergeFrom(loadThemeFile(themePath));
81 } 81 }
82 82
83 const customizations: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations'); 83 const customizations: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations');
84 res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? [])) 84 res.mergeFrom(ColorTheme.fromRules(customizations?.textMateRules ?? []));
85 85
86 return res; 86 return res;
87} 87}
@@ -89,7 +89,7 @@ function loadThemeNamed(themeName: string): ColorTheme {
89function loadThemeFile(themePath: string): ColorTheme { 89function loadThemeFile(themePath: string): ColorTheme {
90 let text; 90 let text;
91 try { 91 try {
92 text = fs.readFileSync(themePath, 'utf8') 92 text = fs.readFileSync(themePath, 'utf8');
93 } catch { 93 } catch {
94 return new ColorTheme(); 94 return new ColorTheme();
95 } 95 }
@@ -119,5 +119,5 @@ function mergeRuleSettings(
119 foreground: override.foreground ?? defaultSetting?.foreground, 119 foreground: override.foreground ?? defaultSetting?.foreground,
120 background: override.background ?? defaultSetting?.background, 120 background: override.background ?? defaultSetting?.background,
121 fontStyle: override.fontStyle ?? defaultSetting?.fontStyle, 121 fontStyle: override.fontStyle ?? defaultSetting?.fontStyle,
122 } 122 };
123} 123}