Fix color decorators not updating when config changes or errors
parent
e3c3ead8ea
commit
d63a97ab15
|
@ -127,4 +127,12 @@ export function registerColorDecorator(
|
|||
window.visibleTextEditors.forEach(updateDecorationsInEditor)
|
||||
}
|
||||
})
|
||||
|
||||
emitter.on('configUpdated', () => {
|
||||
window.visibleTextEditors.forEach(updateDecorationsInEditor)
|
||||
})
|
||||
|
||||
emitter.on('configError', () => {
|
||||
window.visibleTextEditors.forEach(updateDecorationsInEditor)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ export function registerDocumentColorProvider(state: State) {
|
|||
'getDocumentColors',
|
||||
async ({ document }) => {
|
||||
let colors = []
|
||||
if (!state.enabled) return { colors }
|
||||
let doc = state.editor.documents.get(document)
|
||||
if (!doc) return { colors }
|
||||
|
||||
|
|
|
@ -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 @@ connection.onInitialize(
|
|||
// @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 @@ connection.onInitialize(
|
|||
])
|
||||
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 @@ connection.onInitialize(
|
|||
)
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in New Issue