aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/package.json5
-rw-r--r--editors/code/src/scopes.ts38
2 files changed, 19 insertions, 24 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 46b8cd47c..b7ea9fa6f 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -32,8 +32,7 @@
32 }, 32 },
33 "dependencies": { 33 "dependencies": {
34 "seedrandom": "^3.0.1", 34 "seedrandom": "^3.0.1",
35 "vscode-languageclient": "^5.3.0-next.4", 35 "vscode-languageclient": "^5.3.0-next.4"
36 "jsonc-parser": "^2.1.0"
37 }, 36 },
38 "devDependencies": { 37 "devDependencies": {
39 "@types/glob": "^7.1.1", 38 "@types/glob": "^7.1.1",
@@ -494,4 +493,4 @@
494 } 493 }
495 ] 494 ]
496 } 495 }
497} 496} \ No newline at end of file
diff --git a/editors/code/src/scopes.ts b/editors/code/src/scopes.ts
index 607b8b2dd..c9c01ba1d 100644
--- a/editors/code/src/scopes.ts
+++ b/editors/code/src/scopes.ts
@@ -1,5 +1,4 @@
1import * as fs from 'fs' 1import * as fs from 'fs'
2import * as jsonc from 'jsonc-parser'
3import * as path from 'path' 2import * as path from 'path'
4import * as vscode from 'vscode' 3import * as vscode from 'vscode'
5 4
@@ -44,26 +43,21 @@ export function load() {
44 43
45// Find current theme on disk 44// Find current theme on disk
46function loadThemeNamed(themeName: string) { 45function loadThemeNamed(themeName: string) {
47 for (const extension of vscode.extensions.all) {
48 const extensionPath: string = extension.extensionPath
49 const extensionPackageJsonPath: string = path.join(extensionPath, 'package.json')
50 if (!checkFileExists(extensionPackageJsonPath)) {
51 continue
52 }
53 const packageJsonText: string = readFileText(extensionPackageJsonPath)
54 const packageJson: any = jsonc.parse(packageJsonText)
55 if (packageJson.contributes && packageJson.contributes.themes) {
56 for (const theme of packageJson.contributes.themes) {
57 const id = theme.id || theme.label
58 if (id === themeName) {
59 const themeRelativePath: string = theme.path
60 const themeFullPath: string = path.join(extensionPath, themeRelativePath)
61 loadThemeFile(themeFullPath)
62 }
63 }
64 }
65 46
66 } 47 const themePaths = vscode.extensions.all
48 .filter(extension => extension.extensionKind === vscode.ExtensionKind.UI)
49 .filter(extension => extension.packageJSON.contributes)
50 .filter(extension => extension.packageJSON.contributes.themes)
51 .reduce((list, extension) => {
52 const paths = extension.packageJSON.contributes.themes
53 .filter((element: any) => (element.id || element.label) === themeName)
54 .map((element: any) => path.join(extension.extensionPath, element.path))
55 return list.concat(paths)
56 }, Array<string>());
57
58
59 themePaths.forEach(loadThemeFile);
60
67 const customization: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations'); 61 const customization: any = vscode.workspace.getConfiguration('editor').get('tokenColorCustomizations');
68 if (customization && customization.textMateRules) { 62 if (customization && customization.textMateRules) {
69 loadColors(customization.textMateRules) 63 loadColors(customization.textMateRules)
@@ -71,9 +65,11 @@ function loadThemeNamed(themeName: string) {
71} 65}
72 66
73function loadThemeFile(themePath: string) { 67function loadThemeFile(themePath: string) {
68
74 if (checkFileExists(themePath)) { 69 if (checkFileExists(themePath)) {
75 const themeContentText: string = readFileText(themePath) 70 const themeContentText: string = readFileText(themePath)
76 const themeContent: any = jsonc.parse(themeContentText) 71
72 const themeContent: any = JSON.parse(themeContentText)
77 73
78 if (themeContent && themeContent.tokenColors) { 74 if (themeContent && themeContent.tokenColors) {
79 loadColors(themeContent.tokenColors) 75 loadColors(themeContent.tokenColors)