diff options
Diffstat (limited to 'editors/code')
-rw-r--r-- | editors/code/src/scopes.ts | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/editors/code/src/scopes.ts b/editors/code/src/scopes.ts index 76cbbd84e..5d4395930 100644 --- a/editors/code/src/scopes.ts +++ b/editors/code/src/scopes.ts | |||
@@ -55,10 +55,10 @@ function loadThemeNamed(themeName: string) { | |||
55 | const themePaths = vscode.extensions.all | 55 | const themePaths = vscode.extensions.all |
56 | .filter(filterThemeExtensions) | 56 | .filter(filterThemeExtensions) |
57 | .reduce((list, extension) => { | 57 | .reduce((list, extension) => { |
58 | const paths = extension.packageJSON.contributes.themes | 58 | return extension.packageJSON.contributes.themes |
59 | .filter((element: any) => (element.id || element.label) === themeName) | 59 | .filter((element: any) => (element.id || element.label) === themeName) |
60 | .map((element: any) => path.join(extension.extensionPath, element.path)) | 60 | .map((element: any) => path.join(extension.extensionPath, element.path)) |
61 | return list.concat(paths) | 61 | .concat(list) |
62 | }, Array<string>()) | 62 | }, Array<string>()) |
63 | 63 | ||
64 | 64 | ||
@@ -92,7 +92,8 @@ function loadThemeFile(themePath: string) { | |||
92 | .forEach(loadThemeFile) | 92 | .forEach(loadThemeFile) |
93 | } | 93 | } |
94 | 94 | ||
95 | function mergeRuleSettings(defaultSetting: TextMateRuleSettings, override: TextMateRuleSettings): TextMateRuleSettings { | 95 | function mergeRuleSettings(defaultSetting: TextMateRuleSettings | undefined, override: TextMateRuleSettings): TextMateRuleSettings { |
96 | if (defaultSetting === undefined) { return override } | ||
96 | const mergedRule = defaultSetting | 97 | const mergedRule = defaultSetting |
97 | 98 | ||
98 | mergedRule.background = override.background || defaultSetting.background | 99 | mergedRule.background = override.background || defaultSetting.background |
@@ -102,29 +103,21 @@ function mergeRuleSettings(defaultSetting: TextMateRuleSettings, override: TextM | |||
102 | return mergedRule | 103 | return mergedRule |
103 | } | 104 | } |
104 | 105 | ||
105 | function loadColors(textMateRules: TextMateRule[]): void { | 106 | function updateRules(scope: string, updatedSettings: TextMateRuleSettings): void { |
106 | for (const rule of textMateRules) { | 107 | [rules.get(scope)] |
108 | .map(settings => mergeRuleSettings(settings, updatedSettings)) | ||
109 | .forEach(settings => rules.set(scope, settings)) | ||
110 | } | ||
107 | 111 | ||
112 | function loadColors(textMateRules: TextMateRule[]): void { | ||
113 | textMateRules.forEach(rule => { | ||
108 | if (typeof rule.scope === 'string') { | 114 | if (typeof rule.scope === 'string') { |
109 | const existingRule = rules.get(rule.scope) | 115 | updateRules(rule.scope, rule.settings) |
110 | if (existingRule) { | ||
111 | rules.set(rule.scope, mergeRuleSettings(existingRule, rule.settings)) | ||
112 | } | ||
113 | else { | ||
114 | rules.set(rule.scope, rule.settings) | ||
115 | } | ||
116 | } else if (rule.scope instanceof Array) { | ||
117 | for (const scope of rule.scope) { | ||
118 | const existingRule = rules.get(scope) | ||
119 | if (existingRule) { | ||
120 | rules.set(scope, mergeRuleSettings(existingRule, rule.settings)) | ||
121 | } | ||
122 | else { | ||
123 | rules.set(scope, rule.settings) | ||
124 | } | ||
125 | } | ||
126 | } | 116 | } |
127 | } | 117 | else if (rule.scope instanceof Array) { |
118 | rule.scope.forEach(scope => updateRules(scope, rule.settings)) | ||
119 | } | ||
120 | }) | ||
128 | } | 121 | } |
129 | 122 | ||
130 | function isFile(filePath: string): boolean { | 123 | function isFile(filePath: string): boolean { |