tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
diff --git a/src/lib/registerColorDecorator.ts b/src/lib/registerColorDecorator.ts
index 7ae0d7d0c48f8ed0da18dc0b04132699be9b474a..b365b8f594575578047722dcc2da6a54c57bc2b1 100644
--- a/src/lib/registerColorDecorator.ts
+++ b/src/lib/registerColorDecorator.ts
@@ -127,4 +127,12 @@ ) {
window.visibleTextEditors.forEach(updateDecorationsInEditor)
}
})
+
+ emitter.on('configUpdated', () => {
+ window.visibleTextEditors.forEach(updateDecorationsInEditor)
+ })
+
+ emitter.on('configError', () => {
+ window.visibleTextEditors.forEach(updateDecorationsInEditor)
+ })
}
diff --git a/src/lsp/providers/documentColorProvider.ts b/src/lsp/providers/documentColorProvider.ts
index d9ea6a6edf27b3f390ba55d5d3c0e54353e1d5d8..95321aa060179705c14b0156c9a1901c143bd0e3 100644
--- a/src/lsp/providers/documentColorProvider.ts
+++ b/src/lsp/providers/documentColorProvider.ts
@@ -16,6 +16,7 @@ state.editor.connection,
'getDocumentColors',
async ({ document }) => {
let colors = []
+ if (!state.enabled) return { colors }
let doc = state.editor.documents.get(document)
if (!doc) return { colors }
diff --git a/src/lsp/server.ts b/src/lsp/server.ts
index bd7cc22733c16d072d3935776c5c4d24c857855b..c4cb2d1dab02b93616d6f761d90e1ef7050dadd9 100644
--- a/src/lsp/server.ts
+++ b/src/lsp/server.ts
@@ -38,7 +38,7 @@ import { provideCodeActions } from './providers/codeActions/codeActionProvider'
import { registerDocumentColorProvider } from './providers/documentColorProvider'
let connection = createConnection(ProposedFeatures.all)
-let state: State = { enabled: false, emitter: createEmitter(connection) }
+const state: State = { enabled: false, emitter: createEmitter(connection) }
let documents = new TextDocuments()
let workspaceFolder: string | null
@@ -74,7 +74,7 @@ connection.onInitialize(
async (params: InitializeParams): Promise<InitializeResult> => {
const capabilities = params.capabilities
- const editorState: EditorState = {
+ state.editor = {
connection,
documents,
documentSettings,
@@ -100,12 +100,7 @@ {
// @ts-ignore
onChange: (newState: State): void => {
if (newState && !newState.error) {
- state = {
- ...newState,
- enabled: true,
- emitter: state.emitter,
- editor: editorState,
- }
+ Object.assign(state, newState, { enabled: true })
connection.sendNotification('tailwindcss/configUpdated', [
state.configPath,
state.config,
@@ -113,11 +108,7 @@ state.plugins,
])
updateAllDiagnostics(state)
} else {
- state = {
- enabled: false,
- emitter: state.emitter,
- editor: editorState,
- }
+ state.enabled = false
if (newState && newState.error) {
const payload: {
message: string
@@ -141,14 +132,9 @@ }
)
if (tailwindState) {
- state = {
- enabled: true,
- emitter: state.emitter,
- editor: editorState,
- ...tailwindState,
- }
+ Object.assign(state, tailwindState, { enabled: true })
} else {
- state = { enabled: false, emitter: state.emitter, editor: editorState }
+ state.enabled = false
}
return {