ensure diagnostics are updated when the user's tailwind config changes
parent
60cc17be77
commit
3de1b980ad
|
@ -405,3 +405,22 @@ export async function provideDiagnostics(
|
|||
diagnostics,
|
||||
})
|
||||
}
|
||||
|
||||
export function clearDiagnostics(state: State, document: TextDocument): void {
|
||||
state.editor.connection.sendDiagnostics({
|
||||
uri: document.uri,
|
||||
diagnostics: [],
|
||||
})
|
||||
}
|
||||
|
||||
export function clearAllDiagnostics(state: State): void {
|
||||
state.editor.documents.all().forEach((document) => {
|
||||
clearDiagnostics(state, document)
|
||||
})
|
||||
}
|
||||
|
||||
export function updateAllDiagnostics(state: State): void {
|
||||
state.editor.documents.all().forEach((document) => {
|
||||
provideDiagnostics(state, document)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,11 @@ import {
|
|||
import { provideHover } from './providers/hoverProvider'
|
||||
import { URI } from 'vscode-uri'
|
||||
import { getDocumentSettings } from './util/getDocumentSettings'
|
||||
import { provideDiagnostics } from './providers/diagnosticsProvider'
|
||||
import {
|
||||
provideDiagnostics,
|
||||
updateAllDiagnostics,
|
||||
clearAllDiagnostics,
|
||||
} from './providers/diagnosticsProvider'
|
||||
import { createEmitter } from '../lib/emitter'
|
||||
|
||||
let connection = createConnection(ProposedFeatures.all)
|
||||
|
@ -102,6 +106,7 @@ connection.onInitialize(
|
|||
state.config,
|
||||
state.plugins,
|
||||
])
|
||||
updateAllDiagnostics(state)
|
||||
} else {
|
||||
state = {
|
||||
enabled: false,
|
||||
|
@ -122,6 +127,7 @@ connection.onInitialize(
|
|||
}
|
||||
connection.sendNotification('tailwindcss/configError', [payload])
|
||||
}
|
||||
clearAllDiagnostics(state)
|
||||
// TODO
|
||||
// connection.sendNotification('tailwindcss/configUpdated', [null])
|
||||
}
|
||||
|
@ -196,9 +202,7 @@ connection.onDidChangeConfiguration((change) => {
|
|||
)
|
||||
}
|
||||
|
||||
state.editor.documents.all().forEach((doc) => {
|
||||
provideDiagnostics(state, doc)
|
||||
})
|
||||
updateAllDiagnostics(state)
|
||||
})
|
||||
|
||||
connection.onCompletion(
|
||||
|
|
Loading…
Reference in New Issue