@@ -211,12 +211,33 @@ async function createProjectService(
211
211
documentService : DocumentService
212
212
) : Promise < ProjectService > {
213
213
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
+
214
235
const state : State = {
215
236
enabled : false ,
216
237
editor : {
217
238
connection,
218
239
folder,
219
- globalSettings : params . initializationOptions . configuration as Settings ,
240
+ globalSettings : await getConfiguration ( ) ,
220
241
userLanguages : params . initializationOptions . userLanguages
221
242
? params . initializationOptions . userLanguages
222
243
: { } ,
@@ -226,35 +247,17 @@ async function createProjectService(
226
247
diagnosticRelatedInformation : true ,
227
248
} ,
228
249
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,
247
251
getDocumentSymbols : ( uri : string ) => {
248
252
return connection . sendRequest ( '@/tailwindCSS/getDocumentSymbols' , { uri } )
249
253
} ,
250
254
} ,
251
255
}
252
256
253
- const documentSettingsCache : Map < string , Settings > = new Map ( )
254
257
let registrations : Promise < BulkUnregistration >
255
258
256
259
let chokidarWatcher : chokidar . FSWatcher
257
- let ignore = state . editor . globalSettings . tailwindCSS . files . exclude
260
+ let ignore = state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ]
258
261
259
262
function onFileEvents ( changes : Array < { file : string ; type : FileChangeType } > ) : void {
260
263
let needsInit = false
@@ -447,7 +450,7 @@ async function createProjectService(
447
450
let [ configPath ] = (
448
451
await glob ( [ `**/${ CONFIG_FILE_GLOB } ` ] , {
449
452
cwd : folder ,
450
- ignore : state . editor . globalSettings . tailwindCSS . files . exclude ,
453
+ ignore : state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ] ,
451
454
onlyFiles : true ,
452
455
absolute : true ,
453
456
suppressErrors : true ,
@@ -980,9 +983,9 @@ async function createProjectService(
980
983
} ,
981
984
onUpdateSettings ( settings : any ) : void {
982
985
documentSettingsCache . clear ( )
983
- let previousExclude = state . editor . globalSettings . tailwindCSS . files . exclude
986
+ let previousExclude = state . editor . globalSettings . tailwindCSS . files ? .exclude ?? [ ]
984
987
state . editor . globalSettings = settings
985
- if ( ! equal ( previousExclude , settings . tailwindCSS . files . exclude ) ) {
988
+ if ( ! equal ( previousExclude , settings . tailwindCSS . files ? .exclude ?? [ ] ) ) {
986
989
tryInit ( )
987
990
} else {
988
991
if ( state . enabled ) {
0 commit comments