@@ -62,7 +62,6 @@ function sortedWorkspaceFolders(): string[] {
6262 }
6363 return _sortedWorkspaceFolders
6464}
65- Workspace . onDidChangeWorkspaceFolders ( ( ) => ( _sortedWorkspaceFolders = undefined ) )
6665
6766function getOuterMostWorkspaceFolder ( folder : WorkspaceFolder ) : WorkspaceFolder {
6867 let sorted = sortedWorkspaceFolders ( )
@@ -111,28 +110,30 @@ export function activate(context: ExtensionContext) {
111110 // TODO: check if the actual language MAPPING changed
112111 // not just the language IDs
113112 // e.g. "plaintext" already exists but you change it from "html" to "css"
114- Workspace . onDidChangeConfiguration ( ( event ) => {
115- clients . forEach ( ( client , key ) => {
116- const folder = Workspace . getWorkspaceFolder ( Uri . parse ( key ) )
117-
118- if ( event . affectsConfiguration ( 'tailwindCSS' , folder ) ) {
119- const userLanguages = getUserLanguages ( folder )
120- if ( userLanguages ) {
121- const userLanguageIds = Object . keys ( userLanguages )
122- const newLanguages = dedupe ( [ ...DEFAULT_LANGUAGES , ...userLanguageIds ] )
123- if ( ! equal ( newLanguages , languages . get ( folder . uri . toString ( ) ) ) ) {
124- languages . set ( folder . uri . toString ( ) , newLanguages )
125-
126- if ( client ) {
127- clients . delete ( folder . uri . toString ( ) )
128- client . stop ( )
129- bootWorkspaceClient ( folder )
113+ context . subscriptions . push (
114+ Workspace . onDidChangeConfiguration ( ( event ) => {
115+ clients . forEach ( ( client , key ) => {
116+ const folder = Workspace . getWorkspaceFolder ( Uri . parse ( key ) )
117+
118+ if ( event . affectsConfiguration ( 'tailwindCSS' , folder ) ) {
119+ const userLanguages = getUserLanguages ( folder )
120+ if ( userLanguages ) {
121+ const userLanguageIds = Object . keys ( userLanguages )
122+ const newLanguages = dedupe ( [ ...DEFAULT_LANGUAGES , ...userLanguageIds ] )
123+ if ( ! equal ( newLanguages , languages . get ( folder . uri . toString ( ) ) ) ) {
124+ languages . set ( folder . uri . toString ( ) , newLanguages )
125+
126+ if ( client ) {
127+ clients . delete ( folder . uri . toString ( ) )
128+ client . stop ( )
129+ bootWorkspaceClient ( folder )
130+ }
130131 }
131132 }
132133 }
133- }
134+ } )
134135 } )
135- } )
136+ )
136137
137138 function bootWorkspaceClient ( folder : WorkspaceFolder ) {
138139 if ( clients . has ( folder . uri . toString ( ) ) ) {
@@ -146,6 +147,13 @@ export function activate(context: ExtensionContext) {
146147 colorDecorationType = undefined
147148 }
148149 }
150+ context . subscriptions . push ( {
151+ dispose ( ) {
152+ if ( colorDecorationType ) {
153+ colorDecorationType . dispose ( )
154+ }
155+ } ,
156+ } )
149157
150158 // placeholder so we don't boot another server before this one is ready
151159 clients . set ( folder . uri . toString ( ) , null )
@@ -159,6 +167,7 @@ export function activate(context: ExtensionContext) {
159167
160168 if ( ! outputChannel ) {
161169 outputChannel = Window . createOutputChannel ( CLIENT_NAME )
170+ context . subscriptions . push ( outputChannel )
162171 commands . executeCommand ( 'setContext' , 'tailwindCSS.hasOutputChannel' , true )
163172 }
164173
@@ -361,18 +370,22 @@ export function activate(context: ExtensionContext) {
361370 bootWorkspaceClient ( folder )
362371 }
363372
364- Workspace . onDidOpenTextDocument ( didOpenTextDocument )
373+ context . subscriptions . push ( Workspace . onDidOpenTextDocument ( didOpenTextDocument ) )
365374 Workspace . textDocuments . forEach ( didOpenTextDocument )
366- Workspace . onDidChangeWorkspaceFolders ( ( event ) => {
367- for ( let folder of event . removed ) {
368- let client = clients . get ( folder . uri . toString ( ) )
369- if ( client ) {
370- searchedFolders . delete ( folder . uri . toString ( ) )
371- clients . delete ( folder . uri . toString ( ) )
372- client . stop ( )
375+ context . subscriptions . push (
376+ Workspace . onDidChangeWorkspaceFolders ( ( event ) => {
377+ _sortedWorkspaceFolders = undefined
378+
379+ for ( let folder of event . removed ) {
380+ let client = clients . get ( folder . uri . toString ( ) )
381+ if ( client ) {
382+ searchedFolders . delete ( folder . uri . toString ( ) )
383+ clients . delete ( folder . uri . toString ( ) )
384+ client . stop ( )
385+ }
373386 }
374- }
375- } )
387+ } )
388+ )
376389}
377390
378391export function deactivate ( ) : Thenable < void > {
0 commit comments