Skip to content

Commit 41bd9ce

Browse files
committed
Refactor
1 parent 18dcc70 commit 41bd9ce

File tree

1 file changed

+19
-9
lines changed
  • packages/tailwindcss-language-server/src

1 file changed

+19
-9
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,23 @@ export class TW {
122122
await this.initPromise
123123
}
124124

125+
private validateFolderUri(uri: URI): boolean {
126+
if (uri.scheme !== 'file') {
127+
console.warn(
128+
`The workspace folder [${uri.toString()}] will be ignored: it does not use the file scheme.`,
129+
)
130+
return false
131+
}
132+
133+
return true
134+
}
135+
125136
private getWorkspaceFolders(): WorkspaceFolder[] {
126137
if (this.initializeParams.workspaceFolders?.length) {
127138
return this.initializeParams.workspaceFolders.flatMap((folder) => {
128139
let uri = URI.parse(folder.uri)
129-
if (uri.scheme !== 'file') {
130-
console.warn(`Non-file workspace folder will be ignored: ${folder.uri}`)
131-
return []
132-
}
140+
141+
if (!this.validateFolderUri(uri)) return []
133142

134143
return [
135144
{
@@ -143,10 +152,7 @@ export class TW {
143152
if (this.initializeParams.rootUri) {
144153
let uri = URI.parse(this.initializeParams.rootUri)
145154

146-
if (uri.scheme !== 'file') {
147-
console.warn(`Non-file workspace folder will be ignored: ${uri.toString()}`)
148-
return []
149-
}
155+
if (!this.validateFolderUri(uri)) return []
150156

151157
return [
152158
{
@@ -157,9 +163,13 @@ export class TW {
157163
}
158164

159165
if (this.initializeParams.rootPath) {
166+
let uri = URI.file(this.initializeParams.rootPath)
167+
168+
if (!this.validateFolderUri(uri)) return []
169+
160170
return [
161171
{
162-
uri: URI.file(this.initializeParams.rootPath).fsPath,
172+
uri: uri.fsPath,
163173
name: 'Root',
164174
},
165175
]

0 commit comments

Comments
 (0)