@@ -62,7 +62,6 @@ function sortedWorkspaceFolders(): string[] {
62
62
}
63
63
return _sortedWorkspaceFolders
64
64
}
65
- Workspace . onDidChangeWorkspaceFolders ( ( ) => ( _sortedWorkspaceFolders = undefined ) )
66
65
67
66
function getOuterMostWorkspaceFolder ( folder : WorkspaceFolder ) : WorkspaceFolder {
68
67
let sorted = sortedWorkspaceFolders ( )
@@ -111,28 +110,30 @@ export function activate(context: ExtensionContext) {
111
110
// TODO: check if the actual language MAPPING changed
112
111
// not just the language IDs
113
112
// 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
+ }
130
131
}
131
132
}
132
133
}
133
- }
134
+ } )
134
135
} )
135
- } )
136
+ )
136
137
137
138
function bootWorkspaceClient ( folder : WorkspaceFolder ) {
138
139
if ( clients . has ( folder . uri . toString ( ) ) ) {
@@ -146,6 +147,13 @@ export function activate(context: ExtensionContext) {
146
147
colorDecorationType = undefined
147
148
}
148
149
}
150
+ context . subscriptions . push ( {
151
+ dispose ( ) {
152
+ if ( colorDecorationType ) {
153
+ colorDecorationType . dispose ( )
154
+ }
155
+ } ,
156
+ } )
149
157
150
158
// placeholder so we don't boot another server before this one is ready
151
159
clients . set ( folder . uri . toString ( ) , null )
@@ -159,6 +167,7 @@ export function activate(context: ExtensionContext) {
159
167
160
168
if ( ! outputChannel ) {
161
169
outputChannel = Window . createOutputChannel ( CLIENT_NAME )
170
+ context . subscriptions . push ( outputChannel )
162
171
commands . executeCommand ( 'setContext' , 'tailwindCSS.hasOutputChannel' , true )
163
172
}
164
173
@@ -361,18 +370,22 @@ export function activate(context: ExtensionContext) {
361
370
bootWorkspaceClient ( folder )
362
371
}
363
372
364
- Workspace . onDidOpenTextDocument ( didOpenTextDocument )
373
+ context . subscriptions . push ( Workspace . onDidOpenTextDocument ( didOpenTextDocument ) )
365
374
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
+ }
373
386
}
374
- }
375
- } )
387
+ } )
388
+ )
376
389
}
377
390
378
391
export function deactivate ( ) : Thenable < void > {
0 commit comments