diff --git a/packages/tailwindcss-language-server/src/tw.ts b/packages/tailwindcss-language-server/src/tw.ts index cf1f397e..438d66ad 100644 --- a/packages/tailwindcss-language-server/src/tw.ts +++ b/packages/tailwindcss-language-server/src/tw.ts @@ -40,7 +40,7 @@ import resolveFrom from './util/resolveFrom' import * as parcel from './watcher/index.js' import { equal } from '@tailwindcss/language-service/src/util/array' import { CONFIG_GLOB, CSS_GLOB, PACKAGE_LOCK_GLOB } from './lib/constants' -import { clearRequireCache, isObject, changeAffectsFile } from './utils' +import { clearRequireCache, isObject, changeAffectsFile, normalizeDriveLetter } from './utils' import { DocumentService } from './documents' import { createProjectService, type ProjectService } from './projects' import { type SettingsCache, createSettingsCache } from './config' @@ -273,6 +273,7 @@ export class TW { changeLoop: for (let change of changes) { let normalizedFilename = normalizePath(change.file) + normalizedFilename = normalizeDriveLetter(normalizedFilename) for (let ignorePattern of ignore) { let isIgnored = picomatch(ignorePattern, { dot: true }) @@ -312,6 +313,8 @@ export class TW { ...project.projectConfig.config.entries.map((entry) => entry.path), ] + reloadableFiles = reloadableFiles.map(normalizeDriveLetter) + if (!changeAffectsFile(normalizedFilename, reloadableFiles)) continue needsSoftRestart = true diff --git a/packages/tailwindcss-language-server/src/utils.ts b/packages/tailwindcss-language-server/src/utils.ts index bddb5d2c..58baf74c 100644 --- a/packages/tailwindcss-language-server/src/utils.ts +++ b/packages/tailwindcss-language-server/src/utils.ts @@ -70,6 +70,17 @@ export function dirContains(dir: string, file: string): boolean { return !!relative && !relative.startsWith('..') && !path.isAbsolute(relative) } +const WIN_DRIVE_LETTER = /^([a-zA-Z]):/ + +/** + * Windows drive letters are case-insensitive and we may get them as either + * lower or upper case. This function normalizes the drive letter to uppercase + * to be consistent with the rest of the codebase. + */ +export function normalizeDriveLetter(filepath: string) { + return filepath.replace(WIN_DRIVE_LETTER, (_, letter) => letter.toUpperCase() + ':') +} + export function changeAffectsFile(change: string, files: string[]): boolean { for (let file of files) { if (change === file || dirContains(change, file)) {