Skip to content

Commit

Permalink
Add workspace root document selector when there's exactly one active …
Browse files Browse the repository at this point in the history
…project (#711)
  • Loading branch information
bradlc authored Jan 27, 2023
1 parent 862af22 commit 8e70fbb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/tailwindcss-language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ enum DocumentSelectorPriority {
CONTENT_FILE = 1,
CSS_DIRECTORY = 2,
CONFIG_DIRECTORY = 3,
ROOT_DIRECTORY = 4,
PACKAGE_DIRECTORY = 4,
ROOT_DIRECTORY = 5,
}
type DocumentSelector = { pattern: string; priority: DocumentSelectorPriority }

Expand Down Expand Up @@ -1733,7 +1734,7 @@ class TW {
: []),
{
pattern: normalizePath(path.join(getPackageRoot(path.dirname(configPath), base), '**')),
priority: DocumentSelectorPriority.ROOT_DIRECTORY,
priority: DocumentSelectorPriority.PACKAGE_DIRECTORY,
},
]

Expand All @@ -1744,7 +1745,16 @@ class TW {
}
}

if (Object.keys(projects).length > 0) {
let projectKeys = Object.keys(projects)
let projectCount = projectKeys.length

if (projectCount > 0) {
if (projectCount === 1) {
projects[projectKeys[0]].push({
pattern: normalizePath(path.join(base, '**')),
priority: DocumentSelectorPriority.ROOT_DIRECTORY,
})
}
workspaceFolders = Object.entries(projects).map(([configPath, documentSelector]) => {
return {
folder: base,
Expand Down

0 comments on commit 8e70fbb

Please sign in to comment.