@@ -211,12 +211,33 @@ async function createProjectService(
211211 documentService : DocumentService
212212) : Promise < ProjectService > {
213213 const disposables : Disposable [ ] = [ ]
214+ const documentSettingsCache : Map < string , Settings > = new Map ( )
215+
216+ async function getConfiguration ( uri ?: string ) {
217+ if ( documentSettingsCache . has ( uri ) ) {
218+ return documentSettingsCache . get ( uri )
219+ }
220+ let [ editor , tailwindCSS ] = await Promise . all ( [
221+ connection . workspace . getConfiguration ( {
222+ section : 'editor' ,
223+ scopeUri : uri ,
224+ } ) ,
225+ connection . workspace . getConfiguration ( {
226+ section : 'tailwindCSS' ,
227+ scopeUri : uri ,
228+ } ) ,
229+ ] )
230+ let config : Settings = { editor, tailwindCSS }
231+ documentSettingsCache . set ( uri , config )
232+ return config
233+ }
234+
214235 const state : State = {
215236 enabled : false ,
216237 editor : {
217238 connection,
218239 folder,
219- globalSettings : params . initializationOptions . configuration as Settings ,
240+ globalSettings : await getConfiguration ( ) ,
220241 userLanguages : params . initializationOptions . userLanguages
221242 ? params . initializationOptions . userLanguages
222243 : { } ,
@@ -226,35 +247,17 @@ async function createProjectService(
226247 diagnosticRelatedInformation : true ,
227248 } ,
228249 documents : documentService . documents ,
229- getConfiguration : async ( uri ?: string ) => {
230- if ( documentSettingsCache . has ( uri ) ) {
231- return documentSettingsCache . get ( uri )
232- }
233- let [ editor , tailwindCSS ] = await Promise . all ( [
234- connection . workspace . getConfiguration ( {
235- section : 'editor' ,
236- scopeUri : uri ,
237- } ) ,
238- connection . workspace . getConfiguration ( {
239- section : 'tailwindCSS' ,
240- scopeUri : uri ,
241- } ) ,
242- ] )
243- let config : Settings = { editor, tailwindCSS }
244- documentSettingsCache . set ( uri , config )
245- return config
246- } ,
250+ getConfiguration,
247251 getDocumentSymbols : ( uri : string ) => {
248252 return connection . sendRequest ( '@/tailwindCSS/getDocumentSymbols' , { uri } )
249253 } ,
250254 } ,
251255 }
252256
253- const documentSettingsCache : Map < string , Settings > = new Map ( )
254257 let registrations : Promise < BulkUnregistration >
255258
256259 let chokidarWatcher : chokidar . FSWatcher
257- let ignore = state . editor . globalSettings . tailwindCSS . files . exclude
260+ let ignore = state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ]
258261
259262 function onFileEvents ( changes : Array < { file : string ; type : FileChangeType } > ) : void {
260263 let needsInit = false
@@ -447,7 +450,7 @@ async function createProjectService(
447450 let [ configPath ] = (
448451 await glob ( [ `**/${ CONFIG_FILE_GLOB } ` ] , {
449452 cwd : folder ,
450- ignore : state . editor . globalSettings . tailwindCSS . files . exclude ,
453+ ignore : state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ] ,
451454 onlyFiles : true ,
452455 absolute : true ,
453456 suppressErrors : true ,
@@ -980,9 +983,9 @@ async function createProjectService(
980983 } ,
981984 onUpdateSettings ( settings : any ) : void {
982985 documentSettingsCache . clear ( )
983- let previousExclude = state . editor . globalSettings . tailwindCSS . files . exclude
986+ let previousExclude = state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ]
984987 state . editor . globalSettings = settings
985- if ( ! equal ( previousExclude , settings . tailwindCSS . files . exclude ) ) {
988+ if ( ! equal ( previousExclude , settings . tailwindCSS . files ? .exclude ?? [ ] ) ) {
986989 tryInit ( )
987990 } else {
988991 if ( state . enabled ) {
0 commit comments