@@ -17,7 +17,7 @@ import { EnvironmentOverride } from 'vscode/workbench';
1717import { Logger } from 'monaco-languageclient/tools' ;
1818import { FakeWorker as Worker } from './fakeWorker.js' ;
1919import { setUnexpectedErrorHandler } from 'vscode/monaco' ;
20- import { updateUserConfiguration } from '@codingame/monaco-vscode-configuration-service-override' ;
20+ import { initUserConfiguration } from '@codingame/monaco-vscode-configuration-service-override' ;
2121
2222export interface MonacoEnvironmentEnhanced extends monaco . Environment {
2323 vscodeInitialising ?: boolean ;
@@ -94,25 +94,31 @@ export const mergeServices = (overrideServices: monaco.editor.IEditorOverrideSer
9494 }
9595} ;
9696
97- export const initServices = async ( vscodeApiConfig : VscodeApiConfig , instructions : InitServicesInstructions ) => {
97+ export const initServices = async ( vscodeApiConfig : VscodeApiConfig , instructions ? : InitServicesInstructions ) => {
9898 const envEnhanced = initEnhancedMonacoEnvironment ( ) ;
9999
100100 if ( ! ( envEnhanced . vscodeInitialising ?? false ) ) {
101+
101102 if ( envEnhanced . vscodeApiInitialised ?? false ) {
102- instructions . logger ?. debug ( 'Initialization of vscode services can only performed once!' ) ;
103+ instructions ? .logger ?. debug ( 'Initialization of vscode services can only performed once!' ) ;
103104 } else {
104105 envEnhanced . vscodeInitialising = true ;
105- instructions . logger ?. debug ( `Initializing vscode services. Caller: ${ instructions . caller ?? 'unknown' } ` ) ;
106+ instructions ? .logger ?. debug ( `Initializing vscode services. Caller: ${ instructions . caller ?? 'unknown' } ` ) ;
106107
108+ if ( vscodeApiConfig . userConfiguration ?. json !== undefined ) {
109+ await initUserConfiguration ( vscodeApiConfig . userConfiguration . json ) ;
110+ }
107111 await importAllServices ( vscodeApiConfig , instructions ) ;
112+
108113 vscodeApiConfig . viewsConfig ?. viewsInitFunc ?.( ) ;
109- instructions . logger ?. debug ( 'Initialization of vscode services completed successfully.' ) ;
114+ instructions ? .logger ?. debug ( 'Initialization of vscode services completed successfully.' ) ;
110115
111116 envEnhanced . vscodeApiInitialised = true ;
117+ envEnhanced . vscodeInitialising = false ;
112118 }
113-
114- await updateUserConfiguration ( vscodeApiConfig . userConfiguration ?. json ?? JSON . stringify ( { } ) ) ;
115119 }
120+
121+ return envEnhanced . vscodeApiInitialised ;
116122} ;
117123
118124/**
@@ -126,25 +132,25 @@ export const initServices = async (vscodeApiConfig: VscodeApiConfig, instruction
126132 * - languages
127133 * - model
128134 */
129- export const importAllServices = async ( vscodeApiConfig : VscodeApiConfig , instructions : InitServicesInstructions ) => {
135+ export const importAllServices = async ( vscodeApiConfig : VscodeApiConfig , instructions ? : InitServicesInstructions ) => {
130136 const services = await supplyRequiredServices ( ) ;
131137
132138 mergeServices ( services , vscodeApiConfig . serviceOverrides ) ;
133139 await configureExtHostWorker ( vscodeApiConfig . enableExtHostWorker === true , services ) ;
134140
135- reportServiceLoading ( services , instructions . logger ) ;
141+ reportServiceLoading ( services , instructions ? .logger ) ;
136142
137- if ( instructions . performServiceConsistencyChecks === undefined ||
143+ if ( instructions ? .performServiceConsistencyChecks === undefined ||
138144 ( typeof instructions . performServiceConsistencyChecks === 'function' && instructions . performServiceConsistencyChecks ( ) ) ) {
139145 if ( vscodeApiConfig . viewsConfig ?. viewServiceType === 'ViewsService' || vscodeApiConfig . viewsConfig ?. viewServiceType === 'WorkspaceService' ) {
140- await initialize ( services , instructions . htmlContainer , vscodeApiConfig . workspaceConfig , vscodeApiConfig . envOptions ) ;
146+ await initialize ( services , instructions ? .htmlContainer , vscodeApiConfig . workspaceConfig , vscodeApiConfig . envOptions ) ;
141147 } else {
142148 await initialize ( services , undefined , vscodeApiConfig . workspaceConfig , vscodeApiConfig . envOptions ) ;
143149 }
144150 }
145151
146152 setUnexpectedErrorHandler ( ( e ) => {
147- instructions . logger ?. createErrorAndLog ( 'Unexpected error' , e ) ;
153+ instructions ? .logger ?. createErrorAndLog ( 'Unexpected error' , e ) ;
148154 } ) ;
149155} ;
150156
0 commit comments