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