From ac78e1a62d7edd152387a242e94edbaf382e891a Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 28 Jun 2024 14:18:06 -0400 Subject: [PATCH 1/2] Add logs --- .../tailwindcss-language-server/src/tw.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/tailwindcss-language-server/src/tw.ts b/packages/tailwindcss-language-server/src/tw.ts index 0ec39309..f885b390 100644 --- a/packages/tailwindcss-language-server/src/tw.ts +++ b/packages/tailwindcss-language-server/src/tw.ts @@ -505,6 +505,8 @@ export class TW { } } + console.log(`[Global] Preparing projects...`) + await Promise.all( workspaceFolders.map((projectConfig) => this.addProject( @@ -517,18 +519,24 @@ export class TW { ), ) + console.log(`[Global] Initializing projects...`) + // init projects for documents that are _already_ open let readyDocuments: string[] = [] + let enabledProjectCount = 0 for (let document of this.documentService.getAllDocuments()) { let project = this.getProject(document) if (project && !project.enabled()) { project.enable() await project.tryInit() + enabledProjectCount++ } readyDocuments.push(document.uri) } + console.log(`[Global] Initialized ${enabledProjectCount} projects`) + this.setupLSPHandlers() this.disposables.push( @@ -554,6 +562,8 @@ export class TW { if (!isTestMode) return + console.log(`[Global][Test] Sending document notifications...`) + await Promise.all( readyDocuments.map((uri) => this.connection.sendNotification('@/tailwindCSS/documentReady', { @@ -783,17 +793,28 @@ export class TW { return 0 }) for (let selector of documentSelector) { - let fsPath = URI.parse(document.uri).fsPath + let uri = URI.parse(document.uri) let pattern = selector.pattern.replace(/[\[\]{}]/g, (m) => `\\${m}`) + let fsPath = uri.fsPath + let normalPath = uri.path + // This filename comes from VSCode rather than from the filesystem // which means the drive letter *might* be lowercased and we need // to normalize it so that we can compare it properly. fsPath = normalizeDriveLetter(fsPath) - if (pattern.startsWith('!') && picomatch(pattern.slice(1), { dot: true })(fsPath)) { - break + console.log('[GLOBAL] Checking document', { + fsPath, + normalPath, + }) + + if (pattern.startsWith('!')) { + if (picomatch(pattern.slice(1), { dot: true })(fsPath)) { + break + } } + if (picomatch(pattern, { dot: true })(fsPath) && selector.priority < matchedPriority) { matchedProject = project matchedPriority = selector.priority From c54201681bd37733a6186fd697d7273fc1f9611b Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 28 Jun 2024 14:19:18 -0400 Subject: [PATCH 2/2] Attempt match on non-normalized path for a project --- .../tailwindcss-language-server/src/tw.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/tailwindcss-language-server/src/tw.ts b/packages/tailwindcss-language-server/src/tw.ts index f885b390..0f81f3b3 100644 --- a/packages/tailwindcss-language-server/src/tw.ts +++ b/packages/tailwindcss-language-server/src/tw.ts @@ -813,11 +813,35 @@ export class TW { if (picomatch(pattern.slice(1), { dot: true })(fsPath)) { break } + + if (picomatch(pattern.slice(1), { dot: true })(normalPath)) { + console.log('[GLOBAL] Matched ignored non-FS path', { + pattern, + }) + + break + } } if (picomatch(pattern, { dot: true })(fsPath) && selector.priority < matchedPriority) { matchedProject = project matchedPriority = selector.priority + + continue + } + + if ( + picomatch(pattern, { dot: true })(normalPath) && + selector.priority < matchedPriority + ) { + console.log('[GLOBAL] Matched non-FS path', { + pattern, + }) + + matchedProject = project + matchedPriority = selector.priority + + continue } } } else {