clear color decorators when restarting language client
parent
c4a2c254d8
commit
a5a0494003
|
@ -19,7 +19,12 @@ import {
|
||||||
RelativePattern,
|
RelativePattern,
|
||||||
ConfigurationScope,
|
ConfigurationScope,
|
||||||
} from 'vscode'
|
} 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 { DEFAULT_LANGUAGES } from './lib/languages'
|
||||||
import isObject from './util/isObject'
|
import isObject from './util/isObject'
|
||||||
import { dedupe, equal } from 'tailwindcss-language-service/src/util/array'
|
import { dedupe, equal } from 'tailwindcss-language-service/src/util/array'
|
||||||
|
@ -76,8 +81,6 @@ function getUserLanguages(folder?: WorkspaceFolder): Record<string, string> {
|
||||||
return isObject(langs) ? langs : {}
|
return isObject(langs) ? langs : {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let colorDecorationType: TextEditorDecorationType
|
|
||||||
|
|
||||||
export function activate(context: ExtensionContext) {
|
export function activate(context: ExtensionContext) {
|
||||||
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
|
let module = context.asAbsolutePath(path.join('dist', 'server', 'index.js'))
|
||||||
let outputChannel: OutputChannel = Window.createOutputChannel(CLIENT_NAME)
|
let outputChannel: OutputChannel = Window.createOutputChannel(CLIENT_NAME)
|
||||||
|
@ -132,6 +135,14 @@ export function activate(context: ExtensionContext) {
|
||||||
return
|
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
|
// placeholder so we don't boot another server before this one is ready
|
||||||
clients.set(folder.uri.toString(), null)
|
clients.set(folder.uri.toString(), null)
|
||||||
|
|
||||||
|
@ -288,12 +299,7 @@ export function activate(context: ExtensionContext) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
client.onNotification('@/tailwindCSS/clearColors', () => {
|
client.onNotification('@/tailwindCSS/clearColors', () => clearColors())
|
||||||
if (colorDecorationType) {
|
|
||||||
colorDecorationType.dispose()
|
|
||||||
colorDecorationType = undefined
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
client.onRequest('@/tailwindCSS/getDocumentSymbols', async ({ uri }) => {
|
client.onRequest('@/tailwindCSS/getDocumentSymbols', async ({ uri }) => {
|
||||||
return commands.executeCommand<SymbolInformation[]>(
|
return commands.executeCommand<SymbolInformation[]>(
|
||||||
|
@ -303,6 +309,12 @@ export function activate(context: ExtensionContext) {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
client.onDidChangeState(({ newState }) => {
|
||||||
|
if (newState === LanguageClientState.Stopped) {
|
||||||
|
clearColors()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
client.start()
|
client.start()
|
||||||
clients.set(folder.uri.toString(), client)
|
clients.set(folder.uri.toString(), client)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue