tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
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()