diff --git a/src/extension.ts b/src/extension.ts index ae4407b29275ba4bf313556e48053d26f219d672..17b1a72a954b2303bf928ff9bf65db0b737bef57 100755 --- a/src/extension.ts +++ b/src/extension.ts @@ -19,12 +19,7 @@ TextEditorDecorationType, RelativePattern, ConfigurationScope, } from 'vscode' -import { - LanguageClient, - LanguageClientOptions, - TransportKind, - State as LanguageClientState, -} from 'vscode-languageclient/node' +import { LanguageClient, LanguageClientOptions, TransportKind } 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' @@ -80,6 +75,8 @@ function getUserLanguages(folder?: WorkspaceFolder): Record { 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')) @@ -133,14 +130,6 @@ 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 @@ -299,7 +288,12 @@ commands.executeCommand('tailwindCSS.showOutput') } }) - client.onNotification('@/tailwindCSS/clearColors', () => clearColors()) + client.onNotification('@/tailwindCSS/clearColors', () => { + if (colorDecorationType) { + colorDecorationType.dispose() + colorDecorationType = undefined + } + }) client.onRequest('@/tailwindCSS/getDocumentSymbols', async ({ uri }) => { return commands.executeCommand( @@ -307,12 +301,6 @@ 'vscode.executeDocumentSymbolProvider', Uri.parse(uri) ) }) - }) - - client.onDidChangeState(({ newState }) => { - if (newState === LanguageClientState.Stopped) { - clearColors() - } }) client.start()