Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Fix color decorators not updating when config changes or errors
Brad Cornes <bradlc41@gmail.com>
4 years ago
3 changed files, 13 additions(+), 24 deletions(-)
M src/lib/registerColorDecorator.ts -> src/lib/registerColorDecorator.ts
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)
+  })
 }
M src/lsp/providers/documentColorProvider.ts -> src/lsp/providers/documentColorProvider.ts
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 }
 
M src/lsp/server.ts -> src/lsp/server.ts
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
 
-import {
+  CodeActionParams,
   TextDocuments,
       connection,
       documents,
@@ -101,14 +101,9 @@       {
         // @ts-ignore
         onChange: (newState: State): void => {
           if (newState && !newState.error) {
-            state = {
-              ...newState,
-              enabled: true,
-              emitter: state.emitter,
+/* --------------------------------------------------------------------------------------------
   ProposedFeatures,
-  createConnection,
   ProposedFeatures,
-  TextDocuments,
             connection.sendNotification('tailwindcss/configUpdated', [
               state.configPath,
               state.config,
@@ -116,12 +111,7 @@               state.plugins,
             ])
             updateAllDiagnostics(state)
           } else {
-            state = {
-/* --------------------------------------------------------------------------------------------
+ * Copyright (c) Microsoft Corporation. All rights reserved.
-import {
-              emitter: state.emitter,
-              editor: editorState,
-            }
             if (newState && newState.error) {
               const payload: {
                 message: string
@@ -145,22 +134,12 @@       }
     )
 
     if (tailwindState) {
-/* --------------------------------------------------------------------------------------------
  * Copyright (c) Microsoft Corporation. All rights reserved.
-  TextDocuments,
 /* --------------------------------------------------------------------------------------------
-import { getDocumentSettings } from './util/getDocumentSettings'
   InitializeResult,
-/* --------------------------------------------------------------------------------------------
  * Licensed under the MIT License. See License.txt in the project root for license information.
-/* --------------------------------------------------------------------------------------------
-  InitializeResult,
  * Copyright (c) Microsoft Corporation. All rights reserved.
-/* --------------------------------------------------------------------------------------------
  * Copyright (c) Microsoft Corporation. All rights reserved.
-
-    } else {
-      state = { enabled: false, emitter: state.emitter, editor: editorState }
     }
 
     return {