Skip to content

Commit fc0d986

Browse files
committed
Ensure all document selectors have normalized drive letters
1 parent 5731829 commit fc0d986

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

packages/tailwindcss-language-server/src/project-locator.ts

+24-10
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,18 @@ async function* contentSelectorsFromJsConfig(
532532
if (typeof item !== 'string') continue
533533

534534
let filepath = item.startsWith('!')
535-
? `!${path.resolve(contentBase, item.slice(1))}`
535+
? path.resolve(contentBase, item.slice(1))
536536
: path.resolve(contentBase, item)
537537

538+
filepath = normalizePath(filepath)
539+
filepath = normalizeDriveLetter(filepath)
540+
541+
if (item.startsWith('!')) {
542+
filepath = `!${filepath}`
543+
}
544+
538545
yield {
539-
pattern: normalizePath(filepath),
546+
pattern: filepath,
540547
priority: DocumentSelectorPriority.CONTENT_FILE,
541548
}
542549
}
@@ -549,8 +556,11 @@ async function* contentSelectorsFromCssConfig(
549556
let auto = false
550557
for (let item of entry.content) {
551558
if (item.kind === 'file') {
559+
let filepath = item.file
560+
filepath = normalizePath(filepath)
561+
filepath = normalizeDriveLetter(filepath)
552562
yield {
553-
pattern: normalizePath(item.file),
563+
pattern: filepath,
554564
priority: DocumentSelectorPriority.CONTENT_FILE,
555565
}
556566
} else if (item.kind === 'auto' && !auto) {
@@ -603,12 +613,16 @@ async function* detectContentFiles(
603613
if (!result) return
604614

605615
for (let file of result.files) {
606-
yield normalizePath(file)
616+
file = normalizePath(file)
617+
file = normalizeDriveLetter(file)
618+
yield file
607619
}
608620

609621
for (let { base, pattern } of result.globs) {
610622
// Do not normalize the glob itself as it may contain escape sequences
611-
yield normalizePath(base) + '/' + pattern
623+
base = normalizePath(base)
624+
base = normalizeDriveLetter(base)
625+
yield `${base}/${pattern}`
612626
}
613627
} catch {
614628
//
@@ -754,14 +768,14 @@ export async function calculateDocumentSelectors(
754768
if (entry.type !== 'css') continue
755769

756770
selectors.push({
757-
pattern: entry.path,
771+
pattern: normalizeDriveLetter(normalizePath(entry.path)),
758772
priority: DocumentSelectorPriority.CSS_FILE,
759773
})
760774
}
761775

762776
// - Config File
763777
selectors.push({
764-
pattern: config.path,
778+
pattern: normalizeDriveLetter(normalizePath(config.path)),
765779
priority: DocumentSelectorPriority.CONFIG_FILE,
766780
})
767781

@@ -775,20 +789,20 @@ export async function calculateDocumentSelectors(
775789
if (entry.type !== 'css') continue
776790

777791
selectors.push({
778-
pattern: normalizePath(path.join(path.dirname(entry.path), '**')),
792+
pattern: normalizeDriveLetter(normalizePath(path.join(path.dirname(entry.path), '**'))),
779793
priority: DocumentSelectorPriority.CSS_DIRECTORY,
780794
})
781795
}
782796

783797
// - Directory containing the config
784798
selectors.push({
785-
pattern: normalizePath(path.join(path.dirname(config.path), '**')),
799+
pattern: normalizeDriveLetter(normalizePath(path.join(path.dirname(config.path), '**'))),
786800
priority: DocumentSelectorPriority.CONFIG_DIRECTORY,
787801
})
788802

789803
// - Root of package that contains the config
790804
selectors.push({
791-
pattern: normalizePath(path.join(config.packageRoot, '**')),
805+
pattern: normalizeDriveLetter(normalizePath(path.join(config.packageRoot, '**'))),
792806
priority: DocumentSelectorPriority.PACKAGE_DIRECTORY,
793807
})
794808

0 commit comments

Comments
 (0)