diff --git a/packages/tailwindcss-language-server/src/project-locator.ts b/packages/tailwindcss-language-server/src/project-locator.ts index 93f484cc..e102b279 100644 --- a/packages/tailwindcss-language-server/src/project-locator.ts +++ b/packages/tailwindcss-language-server/src/project-locator.ts @@ -16,6 +16,7 @@ import resolveFrom from './util/resolveFrom' import { type Feature, supportedFeatures } from '@tailwindcss/language-service/src/features' import { pathToFileURL } from 'node:url' import { resolveCssImports } from './resolve-css-imports' +import { normalizeDriveLetter } from './utils' export interface ProjectConfig { /** The folder that contains the project */ @@ -70,6 +71,22 @@ export class ProjectLocator { }) } + // Normalize drive letters in filepaths on Windows so paths + // are consistent across the filesystem and the language client + for (let project of projects) { + project.folder = normalizeDriveLetter(project.folder) + project.configPath = normalizeDriveLetter(project.configPath) + project.config.path = normalizeDriveLetter(project.config.path) + + for (let entry of project.config.entries) { + entry.path = normalizeDriveLetter(entry.path) + } + + for (let selector of project.documentSelector) { + selector.pattern = normalizeDriveLetter(selector.pattern) + } + } + return projects } diff --git a/packages/tailwindcss-language-server/src/tw.ts b/packages/tailwindcss-language-server/src/tw.ts index 7fc82afb..0ec39309 100644 --- a/packages/tailwindcss-language-server/src/tw.ts +++ b/packages/tailwindcss-language-server/src/tw.ts @@ -282,6 +282,10 @@ export class TW { changeLoop: for (let change of changes) { let normalizedFilename = normalizePath(change.file) + + // This filename comes from VSCode rather than from the filesystem + // which means the drive letter *might* be lowercased and we need + // to normalize it so that we can compare it properly. normalizedFilename = normalizeDriveLetter(normalizedFilename) for (let ignorePattern of ignore) { @@ -322,8 +326,6 @@ export class TW { ...project.projectConfig.config.entries.map((entry) => entry.path), ] - reloadableFiles = reloadableFiles.map(normalizeDriveLetter) - if (!changeAffectsFile(normalizedFilename, reloadableFiles)) continue needsSoftRestart = true @@ -783,6 +785,12 @@ export class TW { for (let selector of documentSelector) { let fsPath = URI.parse(document.uri).fsPath let pattern = selector.pattern.replace(/[\[\]{}]/g, (m) => `\\${m}`) + + // This filename comes from VSCode rather than from the filesystem + // which means the drive letter *might* be lowercased and we need + // to normalize it so that we can compare it properly. + fsPath = normalizeDriveLetter(fsPath) + if (pattern.startsWith('!') && picomatch(pattern.slice(1), { dot: true })(fsPath)) { break } diff --git a/packages/vscode-tailwindcss/CHANGELOG.md b/packages/vscode-tailwindcss/CHANGELOG.md index c2591923..0764ef8b 100644 --- a/packages/vscode-tailwindcss/CHANGELOG.md +++ b/packages/vscode-tailwindcss/CHANGELOG.md @@ -2,7 +2,7 @@ ## Prerelease -- Nothing yet! +- Normalize Windows drive letters in document URIs ([#980](https://github.com/tailwindlabs/tailwindcss-intellisense/pull/980)) ## 0.12.0