+ // ^
+ let hover = await doc.hover({ line: 0, character: 13 })
+
+ expect(hover).toEqual(null)
+
+ // Create a CSS config file
+ await fs.writeFile(
+ `${root}/app.css`,
+ css`
+ @import 'tailwindcss';
+
+ @theme {
+ --color-primary: #c0ffee;
+ }
+ `,
+ )
+
+ // Create a CSS config file
+ // Notify the server of the config change
+ let didRestart = Promise.race([
+ new Promise((resolve) => {
+ client.conn.onNotification('@/tailwindCSS/serverRestarted', resolve)
+ }),
+ new Promise((_, reject) =>
+ setTimeout(() => reject(new Error('Did not restart in time')), 5000),
+ ),
+ ])
+
+ await client.notifyChangedFiles({
+ changed: [`${root}/app.css`],
+ })
+
+ await didRestart
+
+ // TODO: Sending a shutdown request immediately after a restart
+ // gets lost
+ // await client.shutdown()
+
+ //
+ // ^
+ hover = await doc.hover({ line: 0, character: 13 })
+
+ expect(hover).toEqual({
+ contents: {
+ language: 'css',
+ value: dedent`
+ .text-primary {
+ color: var(--color-primary) /* #c0ffee */;
+ }
+ `,
+ },
+ range: {
+ start: { line: 0, character: 12 },
+ end: { line: 0, character: 24 },
+ },
+ })
+ },
+})
diff --git a/packages/tailwindcss-language-server/tests/utils/client.ts b/packages/tailwindcss-language-server/tests/utils/client.ts
index 681843a8..17db7a1e 100644
--- a/packages/tailwindcss-language-server/tests/utils/client.ts
+++ b/packages/tailwindcss-language-server/tests/utils/client.ts
@@ -12,6 +12,7 @@ import {
DocumentLinkRequest,
DocumentSymbol,
DocumentSymbolRequest,
+ ExitNotification,
FileChangeType,
FileEvent,
Hover,
@@ -19,6 +20,7 @@ import {
ProtocolConnection,
PublishDiagnosticsParams,
Registration,
+ ShutdownRequest,
SymbolInformation,
UnregistrationRequest,
WorkspaceFolder,
@@ -226,6 +228,11 @@ export interface Client extends ClientWorkspace {
* Update the global settings for the server
*/
updateSettings(settings: DeepPartial): Promise
+
+ /**
+ * Shutdown the server
+ */
+ shutdown(): Promise
}
export interface ClientWorkspaceOptions {
@@ -567,6 +574,13 @@ export async function createClient(opts: ClientOptions): Promise {
})
}
+ let didExit = new Promise((resolve) => conn.onNotification(ExitNotification.type, resolve))
+
+ async function shutdown() {
+ await conn.sendRequest(ShutdownRequest.type)
+ await didExit
+ }
+
return {
...clientWorkspaces[0],
get serverCapabilities() {
@@ -576,6 +590,7 @@ export async function createClient(opts: ClientOptions): Promise {
notifyChangedFiles,
workspace,
updateSettings,
+ shutdown,
}
}
diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md
index 2353dd86..353aad73 100644
--- a/packages/vscode-tailwindcss/CHANGELOG.md
+++ b/packages/vscode-tailwindcss/CHANGELOG.md
@@ -3,6 +3,7 @@
## Prerelease
- Simplify completion details for border and outline utilities ([#1384](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1384))
+- Fix error initializing a new project when editing a CSS file ([#1387](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/1387))
# 0.14.19