Skip to content

Commit 8da1197

Browse files
committed
Refactor
1 parent 5dc6bd2 commit 8da1197

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,18 @@ export class ProjectLocator {
382382
if (indexPath && themePath) graph.connect(indexPath, themePath)
383383
if (indexPath && utilitiesPath) graph.connect(indexPath, utilitiesPath)
384384

385+
let roots = Array.from(graph.roots())
386+
387+
roots.sort((a, b) => {
388+
return (
385389
// Sort the graph so potential "roots" appear first
386390
// The entire concept of roots needs to be rethought because it's not always
387391
// clear what the root of a project is. Even when imports are present a file
388392
// may import a file that is the actual "root" of the project.
389-
let roots = Array.from(graph.roots())
390-
391-
roots.sort((a, b) => {
392-
return a.meta.root === b.meta.root ? 0 : a.meta.root ? -1 : 1
393+
Number(b.meta.root) - Number(a.meta.root) ||
394+
// Otherwise stylesheets are kept in discovery order
395+
0
396+
)
393397
})
394398

395399
for (let root of roots) {

0 commit comments

Comments
 (0)