Skip to content

Commit ca215f7

Browse files
committed
fix: handle init documents
1 parent c392424 commit ca215f7

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

packages/tailwindcss-language-server/src/tw.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,10 @@ export class TW {
629629
this.getProject(document)
630630
?.provideAnnotations(document)
631631
.then((annotations) => {
632-
this.connection.sendRequest('@/tailwindCSS/annotations', annotations)
632+
this.connection.sendRequest('@/tailwindCSS/annotations', {
633+
uri: document.uri,
634+
annotations,
635+
})
633636
})
634637
}),
635638
)
@@ -656,11 +659,25 @@ export class TW {
656659
this.getProject(document)
657660
?.provideAnnotations(document)
658661
.then((annotations) => {
659-
this.connection.sendRequest('@/tailwindCSS/annotations', annotations)
662+
this.connection.sendRequest('@/tailwindCSS/annotations', {
663+
uri: document.uri,
664+
annotations,
665+
})
660666
})
661667
}),
662668
)
663669

670+
this.documentService.getAllDocuments().forEach((document) => {
671+
this.getProject(document)
672+
?.provideAnnotations(document)
673+
.then((annotations) => {
674+
this.connection.sendRequest('@/tailwindCSS/annotations', {
675+
uri: document.uri,
676+
annotations,
677+
})
678+
})
679+
})
680+
664681
if (this.initializeParams.capabilities.workspace.workspaceFolders) {
665682
this.disposables.push(
666683
this.connection.workspace.onDidChangeWorkspaceFolders(async (evt) => {

packages/vscode-tailwindcss/src/extension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,10 @@ export async function activate(context: ExtensionContext) {
543543
client.onNotification('@/tailwindCSS/projectInitialized', updateActiveTextEditorContext)
544544
client.onNotification('@/tailwindCSS/projectReset', updateActiveTextEditorContext)
545545
client.onNotification('@/tailwindCSS/projectsDestroyed', resetActiveTextEditorContext)
546-
client.onRequest('@/tailwindCSS/annotations', (ranges) => {
547-
Window.activeTextEditor.setDecorations(underlineDecorationType, ranges)
546+
client.onRequest('@/tailwindCSS/annotations', ({ uri, annotations }) => {
547+
Window.visibleTextEditors
548+
.find((editor) => editor.document.uri.toString() === uri)
549+
?.setDecorations(underlineDecorationType, annotations)
548550
})
549551
client.onRequest('@/tailwindCSS/getDocumentSymbols', showSymbols)
550552

0 commit comments

Comments
 (0)