Skip to content

Commit 3138265

Browse files
committed
Fix document selectors when using experimental.configFile
1 parent 62658cf commit 3138265

File tree

1 file changed

+23
-13
lines changed
  • packages/tailwindcss-language-server/src

1 file changed

+23
-13
lines changed

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

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,11 @@ type ProjectConfig = {
200200
folder: string
201201
configPath?: string
202202
documentSelector?: Array<DocumentSelector>
203+
isUserConfigured: boolean
203204
}
204205

205206
enum DocumentSelectorPriority {
207+
USER_CONFIGURED = 0,
206208
CONFIG_FILE = 0,
207209
CSS_FILE = 0,
208210
CONTENT_FILE = 1,
@@ -448,7 +450,11 @@ async function createProjectService(
448450
if (!isConfigFile && !isDependency && !isPackageFile) continue
449451

450452
if (!enabled) {
451-
if (projectConfig.configPath && (isConfigFile || isDependency)) {
453+
if (
454+
!projectConfig.isUserConfigured &&
455+
projectConfig.configPath &&
456+
(isConfigFile || isDependency)
457+
) {
452458
documentSelector = [
453459
...documentSelector.filter(
454460
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE
@@ -959,17 +965,19 @@ async function createProjectService(
959965
}
960966

961967
/////////////////////
962-
documentSelector = [
963-
...documentSelector.filter(
964-
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE
965-
),
966-
...getContentDocumentSelectorFromConfigFile(
967-
state.configPath,
968-
tailwindcss.version,
969-
projectConfig.folder,
970-
originalConfig
971-
),
972-
]
968+
if (!projectConfig.isUserConfigured) {
969+
documentSelector = [
970+
...documentSelector.filter(
971+
({ priority }) => priority !== DocumentSelectorPriority.CONTENT_FILE
972+
),
973+
...getContentDocumentSelectorFromConfigFile(
974+
state.configPath,
975+
tailwindcss.version,
976+
projectConfig.folder,
977+
originalConfig
978+
),
979+
]
980+
}
973981
//////////////////////
974982

975983
try {
@@ -1610,9 +1618,10 @@ class TW {
16101618
folder: base,
16111619
configPath: path.resolve(base, relativeConfigPath),
16121620
documentSelector: [].concat(relativeDocumentSelectorOrSelectors).map((selector) => ({
1613-
priority: DocumentSelectorPriority.CONTENT_FILE,
1621+
priority: DocumentSelectorPriority.USER_CONFIGURED,
16141622
pattern: path.resolve(base, selector),
16151623
})),
1624+
isUserConfigured: true,
16161625
}
16171626
}
16181627
)
@@ -1706,6 +1715,7 @@ class TW {
17061715
return {
17071716
folder: base,
17081717
configPath,
1718+
isUserConfigured: false,
17091719
documentSelector: documentSelector
17101720
.sort((a, z) => a.priority - z.priority)
17111721
.filter(

0 commit comments

Comments
 (0)