Skip to content

Commit bb72017

Browse files
Pass URI to configuration call not a file path (#982)
* Pass URI to configuration call not a file path oops. Works fine in VSCode but not in some other LSPs (like Zed). It’s technically a malformed request on our side * Don’t break when `settings.editor` is not defined Also fixes an issue in Zed
1 parent d561031 commit bb72017

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

Diff for: packages/tailwindcss-language-server/src/projects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ export async function createProjectService(
10401040
if (state.enabled) {
10411041
refreshDiagnostics()
10421042
}
1043-
if (settings.editor.colorDecorators) {
1043+
if (settings.editor?.colorDecorators) {
10441044
updateCapabilities()
10451045
} else {
10461046
connection.sendNotification('@/tailwindCSS/clearColors')

Diff for: packages/tailwindcss-language-server/src/tw.ts

+7-14
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ export class TW {
153153
// NOTE: We should eventually be smart about avoiding duplicate work. We do
154154
// not necessarily need to set up file watchers, search for projects, read
155155
// configs, etc… per folder. Some of this work should be sharable.
156-
let results = await Promise.allSettled(folders.map((basePath) => this._initFolder(basePath)))
156+
let results = await Promise.allSettled(
157+
folders.map((basePath) => this._initFolder(URI.file(basePath))),
158+
)
157159

158160
for (let [idx, result] of results.entries()) {
159161
if (result.status === 'rejected') {
@@ -164,24 +166,15 @@ export class TW {
164166
await this.listenForEvents()
165167
}
166168

167-
private async _initFolder(base: string): Promise<void> {
169+
private async _initFolder(baseUri: URI): Promise<void> {
170+
let base = baseUri.fsPath
168171
let workspaceFolders: Array<ProjectConfig> = []
169172
let globalSettings = await this.settingsCache.get()
170173
let ignore = globalSettings.tailwindCSS.files.exclude
171174

172175
// Get user languages for the given workspace folder
173-
let userLanguages = globalSettings.tailwindCSS.includeLanguages
174-
175-
try {
176-
let folderSettings = await this.settingsCache.get(base)
177-
userLanguages = folderSettings.tailwindCSS.includeLanguages
178-
} catch (error) {
179-
console.error(
180-
'Unable to get the settings for workspace folder. Using global settings instead.',
181-
error,
182-
)
183-
}
184-
176+
let folderSettings = await this.settingsCache.get(baseUri.toString())
177+
let userLanguages = folderSettings.tailwindCSS.includeLanguages
185178

186179
// Fall back to settings defined in `initializationOptions` if invalid
187180
if (!isObject(userLanguages)) {

0 commit comments

Comments
 (0)