@@ -5,60 +5,60 @@ import { MonacoTheme } from "shared/src/index";
55
66
77async function getCurrentThemeData ( ) : Promise < object | undefined > {
8- const config = workspace . getConfiguration ( ) ;
9- const theme = config . get ( 'workbench.colorTheme' ) as string ;
8+ const config = workspace . getConfiguration ( ) ;
9+ const theme = config . get ( 'workbench.colorTheme' ) as string ;
1010
11- const extension = extensions . all . find ( ext => {
12- const contributes = ext . packageJSON . contributes ;
13- return contributes && contributes . themes && contributes . themes . some ( ( t : { label : string ; } ) => t . label === theme ) ;
14- } ) ;
11+ const extension = extensions . all . find ( ext => {
12+ const contributes = ext . packageJSON . contributes ;
13+ return contributes && contributes . themes && contributes . themes . some ( ( t : { label : string ; } ) => t . label === theme ) ;
14+ } ) ;
1515
16- if ( ! extension ) {
17- return undefined ;
18- }
16+ if ( ! extension ) {
17+ return undefined ;
18+ }
1919
20- const themeInfo = extension . packageJSON . contributes . themes . find ( ( t : { label : string ; } ) => t . label === theme ) ;
21- const themePath = path . join ( extension . extensionPath , themeInfo . path ) ;
20+ const themeInfo = extension . packageJSON . contributes . themes . find ( ( t : { label : string ; } ) => t . label === theme ) ;
21+ const themePath = path . join ( extension . extensionPath , themeInfo . path ) ;
2222
23- return JSON . parse ( await readFile ( themePath , 'utf8' ) ) ;
23+ return JSON . parse ( await readFile ( themePath , 'utf8' ) ) ;
2424}
2525
2626function convertVSCodeThemeToMonacoTheme ( themeData : any ) : MonacoTheme {
27- const monacoTheme = {
28- base : getMonacoBaseTheme ( themeData . type ) ,
29- inherit : true ,
30- rules : [ ] as any ,
31- colors : { } as any
32- } as MonacoTheme ;
27+ const monacoTheme = {
28+ base : getMonacoBaseTheme ( themeData . type ) ,
29+ inherit : true ,
30+ rules : [ ] as any ,
31+ colors : { } as any
32+ } as MonacoTheme ;
3333
34- monacoTheme . colors [ 'editor.background' ] = themeData . colors [ 'editor.background' ] ;
35- monacoTheme . colors [ 'editor.foreground' ] = themeData . colors [ 'editor.foreground' ] ;
34+ monacoTheme . colors [ 'editor.background' ] = themeData . colors [ 'editor.background' ] ;
35+ monacoTheme . colors [ 'editor.foreground' ] = themeData . colors [ 'editor.foreground' ] ;
3636
37- monacoTheme . rules = themeData . tokenColors ?. map ( ( token : any ) => ( {
38- token : token . scope ,
39- foreground : token . settings . foreground ,
40- background : token . settings . background ,
41- fontStyle : token . settings . fontStyle
42- } ) ) ?? [ ] ;
37+ monacoTheme . rules = themeData . tokenColors ?. map ( ( token : any ) => ( {
38+ token : token . scope ,
39+ foreground : token . settings . foreground ,
40+ background : token . settings . background ,
41+ fontStyle : token . settings . fontStyle
42+ } ) ) ?? [ ] ;
4343
44- return monacoTheme ;
44+ return monacoTheme ;
4545}
4646
4747function getMonacoBaseTheme ( vscodeThemeType : string | MonacoTheme [ 'base' ] ) : MonacoTheme [ 'base' ] {
48- switch ( vscodeThemeType ) {
49- case 'vs' :
50- case 'vs-dark' :
51- case 'hc-black' :
52- return vscodeThemeType ;
53- default :
54- return 'vs-dark' ;
55- }
48+ switch ( vscodeThemeType ) {
49+ case 'vs' :
50+ case 'vs-dark' :
51+ case 'hc-black' :
52+ return vscodeThemeType ;
53+ default :
54+ return 'vs-dark' ;
55+ }
5656}
5757
5858export async function getMonacoTheme ( ) {
59- const themeData = await getCurrentThemeData ( ) ;
60- if ( ! themeData ) {
61- throw new Error ( 'Theme data is undefined' ) ;
62- }
63- return convertVSCodeThemeToMonacoTheme ( themeData ) ;
59+ const themeData = await getCurrentThemeData ( ) ;
60+ if ( ! themeData ) {
61+ throw new Error ( 'Theme data is undefined' ) ;
62+ }
63+ return convertVSCodeThemeToMonacoTheme ( themeData ) ;
6464}
0 commit comments