1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
diff --git a/src/extension.ts b/src/extension.ts
index 17b1a72a954b2303bf928ff9bf65db0b737bef57..ae4407b29275ba4bf313556e48053d26f219d672 100755
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -19,7 +19,12 @@ TextEditorDecorationType,
RelativePattern,
ConfigurationScope,
} from 'vscode'
-import { LanguageClient, LanguageClientOptions, TransportKind } from 'vscode-languageclient/node'
+import {
+ LanguageClient,
+ LanguageClientOptions,
+ TransportKind,
+ State as LanguageClientState,
+} from 'vscode-languageclient/node'
import { DEFAULT_LANGUAGES } from './lib/languages'
import isObject from './util/isObject'
import { dedupe, equal } from 'tailwindcss-language-service/src/util/array'
@@ -75,8 +80,6 @@ function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
const langs = Workspace.getConfiguration('tailwindCSS', folder).includeLanguages
return isObject(langs) ? langs : {}
}
-
-let colorDecorationType: TextEditorDecorationType
export function activate(context: ExtensionContext) {
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
@@ -130,6 +133,14 @@
function bootWorkspaceClient(folder: WorkspaceFolder) {
if (clients.has(folder.uri.toString())) {
return
+ }
+
+ let colorDecorationType: TextEditorDecorationType
+ function clearColors(): void {
+ if (colorDecorationType) {
+ colorDecorationType.dispose()
+ colorDecorationType = undefined
+ }
}
// placeholder so we don't boot another server before this one is ready
@@ -288,12 +299,7 @@ commands.executeCommand('tailwindCSS.showOutput')
}
})
- client.onNotification('@/tailwindCSS/clearColors', () => {
- if (colorDecorationType) {
- colorDecorationType.dispose()
- colorDecorationType = undefined
- }
- })
+ client.onNotification('@/tailwindCSS/clearColors', () => clearColors())
client.onRequest('@/tailwindCSS/getDocumentSymbols', async ({ uri }) => {
return commands.executeCommand<SymbolInformation[]>(
@@ -301,6 +307,12 @@ 'vscode.executeDocumentSymbolProvider',
Uri.parse(uri)
)
})
+ })
+
+ client.onDidChangeState(({ newState }) => {
+ if (newState === LanguageClientState.Stopped) {
+ clearColors()
+ }
})
client.start()
|