Skip to content

Commit f626cd4

Browse files
committed
Fix matching behavior when config file isn’t in root
1 parent bb0aa26 commit f626cd4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ export interface ProjectConfig {
2727
/** The list of documents that are related to this project */
2828
documentSelector: DocumentSelector[]
2929

30+
/**
31+
* Additional selectors that should be matched with this project
32+
*
33+
* These are *never* reset
34+
*/
35+
additionalSelectors: DocumentSelector[]
36+
3037
/** Whether or not this project was explicitly defined by the user */
3138
isUserConfigured: boolean
3239

@@ -65,7 +72,7 @@ export class ProjectLocator {
6572
}
6673

6774
if (projects.length === 1) {
68-
projects[0].documentSelector.push({
75+
projects[0].additionalSelectors.push({
6976
pattern: normalizePath(path.join(this.base, '**')),
7077
priority: DocumentSelectorPriority.ROOT_DIRECTORY,
7178
})
@@ -132,6 +139,7 @@ export class ProjectLocator {
132139
priority: DocumentSelectorPriority.USER_CONFIGURED,
133140
pattern: selector,
134141
})),
142+
additionalSelectors: [],
135143
tailwind,
136144
}
137145
}
@@ -214,6 +222,7 @@ export class ProjectLocator {
214222
isUserConfigured: false,
215223
configPath: config.path,
216224
documentSelector: selectors,
225+
additionalSelectors: [],
217226
tailwind,
218227
}
219228
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ export async function createProjectService(
11741174

11751175
state,
11761176
documentSelector() {
1177-
return documentSelector
1177+
return [...documentSelector, ...projectConfig.additionalSelectors]
11781178
},
11791179
tryInit,
11801180
async dispose() {

0 commit comments

Comments
 (0)