@@ -246,6 +246,15 @@ export async function activate(context: ExtensionContext) {
246
246
// e.g. "plaintext" already exists but you change it from "html" to "css"
247
247
context . subscriptions . push (
248
248
Workspace . onDidChangeConfiguration ( ( event ) => {
249
+ let toReboot = new Set < WorkspaceFolder > ( )
250
+
251
+ Workspace . textDocuments . forEach ( ( document ) => {
252
+ let folder = Workspace . getWorkspaceFolder ( document . uri )
253
+ if ( ! folder ) return
254
+ if ( event . affectsConfiguration ( 'tailwindCSS.experimental.configFile' , folder ) ) {
255
+ toReboot . add ( folder )
256
+ }
257
+ } )
249
258
; [ ...clients ] . forEach ( ( [ key , client ] ) => {
250
259
const folder = Workspace . getWorkspaceFolder ( Uri . parse ( key ) )
251
260
let reboot = false
@@ -267,11 +276,15 @@ export async function activate(context: ExtensionContext) {
267
276
}
268
277
269
278
if ( reboot && client ) {
270
- clients . delete ( folder . uri . toString ( ) )
271
- client . stop ( )
272
- bootWorkspaceClient ( folder )
279
+ toReboot . add ( folder )
273
280
}
274
281
} )
282
+
283
+ for ( let folder of toReboot ) {
284
+ clients . get ( folder . uri . toString ( ) ) ?. stop ( )
285
+ clients . delete ( folder . uri . toString ( ) )
286
+ bootClientForFolderIfNeeded ( folder )
287
+ }
275
288
} )
276
289
)
277
290
@@ -568,6 +581,8 @@ export async function activate(context: ExtensionContext) {
568
581
} ,
569
582
initializationOptions : {
570
583
userLanguages : getUserLanguages ( folder ) ,
584
+ workspaceFile :
585
+ Workspace . workspaceFile ?. scheme === 'file' ? Workspace . workspaceFile . fsPath : undefined ,
571
586
} ,
572
587
synchronize : {
573
588
configurationSection : [ 'files' , 'editor' , 'tailwindCSS' ] ,
@@ -602,29 +617,12 @@ export async function activate(context: ExtensionContext) {
602
617
clients . set ( folder . uri . toString ( ) , client )
603
618
}
604
619
605
- async function didOpenTextDocument ( document : TextDocument ) : Promise < void > {
606
- if ( document . languageId === 'tailwindcss' ) {
607
- bootCssServer ( )
608
- }
609
-
610
- // We are only interested in language mode text
611
- if ( document . uri . scheme !== 'file' ) {
612
- return
613
- }
614
-
615
- let uri = document . uri
616
- let folder = Workspace . getWorkspaceFolder ( uri )
617
- // Files outside a folder can't be handled. This might depend on the language.
618
- // Single file languages like JSON might handle files outside the workspace folders.
619
- if ( ! folder ) {
620
+ async function bootClientForFolderIfNeeded ( folder : WorkspaceFolder ) : Promise < void > {
621
+ let settings = Workspace . getConfiguration ( 'tailwindCSS' , folder )
622
+ if ( settings . get ( 'experimental.configFile' ) !== null ) {
623
+ bootWorkspaceClient ( folder )
620
624
return
621
625
}
622
- // If we have nested workspace folders we only start a server on the outer most workspace folder.
623
- folder = getOuterMostWorkspaceFolder ( folder )
624
-
625
- if ( searchedFolders . has ( folder . uri . toString ( ) ) ) return
626
-
627
- searchedFolders . add ( folder . uri . toString ( ) )
628
626
629
627
let [ configFile ] = await Workspace . findFiles (
630
628
new RelativePattern ( folder , `**/${ CONFIG_GLOB } ` ) ,
@@ -650,6 +648,35 @@ export async function activate(context: ExtensionContext) {
650
648
}
651
649
}
652
650
651
+ async function didOpenTextDocument ( document : TextDocument ) : Promise < void > {
652
+ if ( document . languageId === 'tailwindcss' ) {
653
+ bootCssServer ( )
654
+ }
655
+
656
+ // We are only interested in language mode text
657
+ if ( document . uri . scheme !== 'file' ) {
658
+ return
659
+ }
660
+
661
+ let uri = document . uri
662
+ let folder = Workspace . getWorkspaceFolder ( uri )
663
+ // Files outside a folder can't be handled. This might depend on the language.
664
+ // Single file languages like JSON might handle files outside the workspace folders.
665
+ if ( ! folder ) {
666
+ return
667
+ }
668
+ // If we have nested workspace folders we only start a server on the outer most workspace folder.
669
+ folder = getOuterMostWorkspaceFolder ( folder )
670
+
671
+ if ( searchedFolders . has ( folder . uri . toString ( ) ) ) {
672
+ return
673
+ }
674
+
675
+ searchedFolders . add ( folder . uri . toString ( ) )
676
+
677
+ await bootClientForFolderIfNeeded ( folder )
678
+ }
679
+
653
680
context . subscriptions . push ( Workspace . onDidOpenTextDocument ( didOpenTextDocument ) )
654
681
Workspace . textDocuments . forEach ( didOpenTextDocument )
655
682
context . subscriptions . push (
0 commit comments