From 09930e228efb69dbb82f2d39dc1631a137a6cd58 Mon Sep 17 00:00:00 2001 From: Andrew Ewing Date: Tue, 5 Aug 2025 15:48:31 -0700 Subject: [PATCH 1/7] fix: respect tsconfig exclude patterns in file watcher - Add getProjectConfig() to language server to expose parsed tsconfig - Process wildcard directories in svelte-check to determine watch paths - Support both recursive and non-recursive directory watching based on TypeScript's configuration - Handle relative paths correctly for directories outside workspace This ensures svelte-check only watches directories included by the tsconfig, improving performance and avoiding unnecessary file watching. --- .../src/plugins/typescript/service.ts | 6 ++ packages/language-server/src/svelte-check.ts | 21 ++++++ packages/svelte-check/src/index.ts | 69 ++++++++++++++----- 3 files changed, 80 insertions(+), 16 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/service.ts b/packages/language-server/src/plugins/typescript/service.ts index c2cf2e02d..cffba1ae0 100644 --- a/packages/language-server/src/plugins/typescript/service.ts +++ b/packages/language-server/src/plugins/typescript/service.ts @@ -60,6 +60,7 @@ export interface LanguageServiceContainer { getResolvedProjectReferences(): TsConfigInfo[]; openVirtualDocument(document: Document): void; isShimFiles(filePath: string): boolean; + getProjectConfig(): ts.ParsedCommandLine; dispose(): void; } @@ -458,6 +459,7 @@ async function createLanguageService( getResolvedProjectReferences, openVirtualDocument, isShimFiles, + getProjectConfig, dispose }; @@ -1249,6 +1251,10 @@ async function createLanguageService( function isShimFiles(filePath: string) { return svelteTsxFilesToOriginalCasing.has(getCanonicalFileName(normalizePath(filePath))); } + + function getProjectConfig() { + return projectConfig; + } } /** diff --git a/packages/language-server/src/svelte-check.ts b/packages/language-server/src/svelte-check.ts index 75a62b173..e055d1a03 100644 --- a/packages/language-server/src/svelte-check.ts +++ b/packages/language-server/src/svelte-check.ts @@ -353,4 +353,25 @@ export class SvelteCheck { } return this.lsAndTSDocResolver.getTSService(tsconfigPath); } + + /** + * Gets the watch directories based on the tsconfig include patterns. + * Returns null if no tsconfig is specified. + */ + async getWatchDirectories(): Promise<{ path: string; recursive: boolean }[] | null> { + if (!this.options.tsconfig) { + return null; + } + const lsContainer = await this.getLSContainer(this.options.tsconfig); + const projectConfig = lsContainer.getProjectConfig(); + + if (!projectConfig.wildcardDirectories) { + return null; + } + + return Object.entries(projectConfig.wildcardDirectories).map(([dir, flags]) => ({ + path: dir, + recursive: !!(flags & ts.WatchDirectoryFlags.Recursive) + })); + } } diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 25749a164..21229fa76 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -143,35 +143,42 @@ async function getDiagnostics( } } +const FILE_ENDING_REGEX = /\.(svelte|d\.ts|ts|js|jsx|tsx|mjs|cjs|mts|cts)$/; +const VITE_CONFIG_REGEX = /vite\.config\.(js|ts)\.timestamp-/; + class DiagnosticsWatcher { private updateDiagnostics: any; + private watcher: any; + private currentWatchedDirs = new Set(); + private userIgnored: Array<(path: string) => boolean>; constructor( private workspaceUri: URI, private svelteCheck: SvelteCheck, private writer: Writer, filePathsToIgnore: string[], - ignoreInitialAdd: boolean + private ignoreInitialAdd: boolean ) { - const fileEnding = /\.(svelte|d\.ts|ts|js|jsx|tsx|mjs|cjs|mts|cts)$/; - const viteConfigRegex = /vite\.config\.(js|ts)\.timestamp-/; - const userIgnored = createIgnored(filePathsToIgnore); - const offset = workspaceUri.fsPath.length + 1; + this.userIgnored = createIgnored(filePathsToIgnore); - watch(workspaceUri.fsPath, { + // Create watcher with initial paths + this.watcher = watch([], { ignored: (path, stats) => { if ( path.includes('node_modules') || path.includes('.git') || - (stats?.isFile() && (!fileEnding.test(path) || viteConfigRegex.test(path))) + (stats?.isFile() && (!FILE_ENDING_REGEX.test(path) || VITE_CONFIG_REGEX.test(path))) ) { return true; } - if (userIgnored.length !== 0) { - path = path.slice(offset); - for (const i of userIgnored) { - if (i(path)) { + if (this.userIgnored.length !== 0) { + // Make path relative to workspace for user ignores + const workspaceRelative = path.startsWith(this.workspaceUri.fsPath) + ? path.slice(this.workspaceUri.fsPath.length + 1) + : path; + for (const i of this.userIgnored) { + if (i(workspaceRelative)) { return true; } } @@ -179,13 +186,38 @@ class DiagnosticsWatcher { return false; }, - ignoreInitial: ignoreInitialAdd + ignoreInitial: this.ignoreInitialAdd }) .on('add', (path) => this.updateDocument(path, true)) .on('unlink', (path) => this.removeDocument(path)) .on('change', (path) => this.updateDocument(path, false)); - if (ignoreInitialAdd) { + this.updateWatchedDirectories(); + } + + private async updateWatchedDirectories() { + const watchDirs = await this.svelteCheck.getWatchDirectories(); + const dirsToWatch = watchDirs || [{ path: this.workspaceUri.fsPath, recursive: true }]; + const newDirs = new Set(dirsToWatch.map(d => d.path)); + + // Fast diff: find directories to add and remove + const toAdd = [...newDirs].filter(dir => !this.currentWatchedDirs.has(dir)); + const toRemove = [...this.currentWatchedDirs].filter(dir => !newDirs.has(dir)); + + // Add new directories + if (toAdd.length > 0) { + this.watcher.add(toAdd); + } + + // Remove old directories + if (toRemove.length > 0) { + this.watcher.unwatch(toRemove); + } + + // Update current set + this.currentWatchedDirs = newDirs; + + if (this.ignoreInitialAdd) { this.scheduleDiagnostics(); } } @@ -210,10 +242,15 @@ class DiagnosticsWatcher { this.scheduleDiagnostics(); } - scheduleDiagnostics() { + scheduleDiagnostics(updateWatchers = false) { clearTimeout(this.updateDiagnostics); this.updateDiagnostics = setTimeout( - () => getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck), + async () => { + if (updateWatchers) { + await this.updateWatchedDirectories(); + } + getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck); + }, 1000 ); } @@ -264,7 +301,7 @@ parseOptions(async (opts) => { }; if (opts.watch) { - svelteCheckOptions.onProjectReload = () => watcher.scheduleDiagnostics(); + svelteCheckOptions.onProjectReload = () => watcher.scheduleDiagnostics(true); const watcher = new DiagnosticsWatcher( opts.workspaceUri, new SvelteCheck(opts.workspaceUri.fsPath, svelteCheckOptions), From ea510521e2d8b5a8c962850d7cbd513eafb7db82 Mon Sep 17 00:00:00 2001 From: Andrew Ewing Date: Wed, 6 Aug 2025 16:03:05 -0700 Subject: [PATCH 2/7] refactor: separate watcher updates from diagnostics scheduling --- packages/svelte-check/src/index.ts | 33 +++++++++++++++++------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 21229fa76..01662c958 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -2,7 +2,7 @@ * This code's groundwork is taken from https://github.com/vuejs/vetur/tree/master/vti */ -import { watch } from 'chokidar'; +import { watch, FSWatcher } from 'chokidar'; import * as fs from 'fs'; import { fdir } from 'fdir'; import * as path from 'path'; @@ -148,9 +148,10 @@ const VITE_CONFIG_REGEX = /vite\.config\.(js|ts)\.timestamp-/; class DiagnosticsWatcher { private updateDiagnostics: any; - private watcher: any; + private watcher: FSWatcher; private currentWatchedDirs = new Set(); private userIgnored: Array<(path: string) => boolean>; + private pendingWatcherUpdate: any; constructor( private workspaceUri: URI, @@ -167,7 +168,8 @@ class DiagnosticsWatcher { if ( path.includes('node_modules') || path.includes('.git') || - (stats?.isFile() && (!FILE_ENDING_REGEX.test(path) || VITE_CONFIG_REGEX.test(path))) + (stats?.isFile() && + (!FILE_ENDING_REGEX.test(path) || VITE_CONFIG_REGEX.test(path))) ) { return true; } @@ -198,11 +200,11 @@ class DiagnosticsWatcher { private async updateWatchedDirectories() { const watchDirs = await this.svelteCheck.getWatchDirectories(); const dirsToWatch = watchDirs || [{ path: this.workspaceUri.fsPath, recursive: true }]; - const newDirs = new Set(dirsToWatch.map(d => d.path)); + const newDirs = new Set(dirsToWatch.map((d) => d.path)); // Fast diff: find directories to add and remove - const toAdd = [...newDirs].filter(dir => !this.currentWatchedDirs.has(dir)); - const toRemove = [...this.currentWatchedDirs].filter(dir => !newDirs.has(dir)); + const toAdd = [...newDirs].filter((dir) => !this.currentWatchedDirs.has(dir)); + const toRemove = [...this.currentWatchedDirs].filter((dir) => !newDirs.has(dir)); // Add new directories if (toAdd.length > 0) { @@ -242,15 +244,15 @@ class DiagnosticsWatcher { this.scheduleDiagnostics(); } - scheduleDiagnostics(updateWatchers = false) { + updateWatchers() { + clearTimeout(this.pendingWatcherUpdate); + this.pendingWatcherUpdate = setTimeout(() => this.updateWatchedDirectories(), 1000); + } + + scheduleDiagnostics() { clearTimeout(this.updateDiagnostics); this.updateDiagnostics = setTimeout( - async () => { - if (updateWatchers) { - await this.updateWatchedDirectories(); - } - getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck); - }, + () => getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck), 1000 ); } @@ -301,7 +303,10 @@ parseOptions(async (opts) => { }; if (opts.watch) { - svelteCheckOptions.onProjectReload = () => watcher.scheduleDiagnostics(true); + svelteCheckOptions.onProjectReload = () => { + watcher.updateWatchers(); + watcher.scheduleDiagnostics(); + }; const watcher = new DiagnosticsWatcher( opts.workspaceUri, new SvelteCheck(opts.workspaceUri.fsPath, svelteCheckOptions), From 12f3c0cfc559ef3a8a1dca56915cbd702ac5125e Mon Sep 17 00:00:00 2001 From: Andrew Ewing Date: Wed, 6 Aug 2025 16:11:30 -0700 Subject: [PATCH 3/7] prettier fix --- packages/language-server/src/svelte-check.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/language-server/src/svelte-check.ts b/packages/language-server/src/svelte-check.ts index e055d1a03..d51907cc9 100644 --- a/packages/language-server/src/svelte-check.ts +++ b/packages/language-server/src/svelte-check.ts @@ -364,11 +364,11 @@ export class SvelteCheck { } const lsContainer = await this.getLSContainer(this.options.tsconfig); const projectConfig = lsContainer.getProjectConfig(); - + if (!projectConfig.wildcardDirectories) { return null; } - + return Object.entries(projectConfig.wildcardDirectories).map(([dir, flags]) => ({ path: dir, recursive: !!(flags & ts.WatchDirectoryFlags.Recursive) From c63b64fb66c85ca9196a4fa9fb97a357df2c685c Mon Sep 17 00:00:00 2001 From: Andrew Ewing Date: Mon, 11 Aug 2025 22:21:37 -0700 Subject: [PATCH 4/7] fix: discover missed watch directories with snapshots --- .../plugins/typescript/LSAndTSDocResolver.ts | 19 +++++++++++++++++++ packages/language-server/src/svelte-check.ts | 8 +++++++- packages/svelte-check/src/index.ts | 17 ++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts b/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts index b62680027..c4b7beb29 100644 --- a/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts +++ b/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts @@ -46,6 +46,11 @@ interface LSAndTSDocResolverOptions { tsSystem?: ts.System; watchDirectory?: (patterns: RelativePattern[]) => void; nonRecursiveWatchPattern?: string; + /** + * Optional callback invoked when a new snapshot is created. + * Used by svelte-check to dynamically add parent directories to file watchers. + */ + onSnapshotCreated?: (dirPath: string) => void; } export class LSAndTSDocResolver { @@ -83,6 +88,20 @@ export class LSAndTSDocResolver { this.tsSystem = this.wrapWithPackageJsonMonitoring(this.options?.tsSystem ?? ts.sys); this.globalSnapshotsManager = new GlobalSnapshotsManager(this.tsSystem); + // Notify when new snapshots are created so external watchers (svelte-check) + // can add their parent directories dynamically. + if (this.options?.onSnapshotCreated) { + this.globalSnapshotsManager.onChange((fileName, newDocument) => { + if (newDocument) { + try { + const dir = dirname(fileName); + this.options?.onSnapshotCreated?.(dir); + } catch { + // best-effort; ignore errors in callback + } + } + }); + } this.userPreferencesAccessor = { preferences: this.getTsUserPreferences() }; const projectService = createProjectService(this.tsSystem, this.userPreferencesAccessor); diff --git a/packages/language-server/src/svelte-check.ts b/packages/language-server/src/svelte-check.ts index d51907cc9..84a26cec6 100644 --- a/packages/language-server/src/svelte-check.ts +++ b/packages/language-server/src/svelte-check.ts @@ -31,6 +31,11 @@ export interface SvelteCheckOptions { tsconfig?: string; onProjectReload?: () => void; watch?: boolean; + /** + * Optional callback invoked when a new snapshot is created. + * Used by svelte-check to dynamically add watch directories. + */ + onSnapshotCreated?: (dirPath: string) => void; } /** @@ -91,7 +96,8 @@ export class SvelteCheck { tsconfigPath: options.tsconfig, isSvelteCheck: true, onProjectReloaded: options.onProjectReload, - watch: options.watch + watch: options.watch, + onSnapshotCreated: options.onSnapshotCreated } ); this.pluginHost.register( diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 01662c958..44a163795 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -197,6 +197,16 @@ class DiagnosticsWatcher { this.updateWatchedDirectories(); } + addWatchDirectory(dir: string) { + if (!dir || this.currentWatchedDirs.has(dir)) { + return; + } + this.watcher.add(dir); + this.currentWatchedDirs.add(dir); + // New files might now be visible; schedule a run + this.scheduleDiagnostics(); + } + private async updateWatchedDirectories() { const watchDirs = await this.svelteCheck.getWatchDirectories(); const dirsToWatch = watchDirs || [{ path: this.workspaceUri.fsPath, recursive: true }]; @@ -303,11 +313,16 @@ parseOptions(async (opts) => { }; if (opts.watch) { + // Wire callbacks that can reference the watcher instance created below + let watcher: DiagnosticsWatcher; svelteCheckOptions.onProjectReload = () => { watcher.updateWatchers(); watcher.scheduleDiagnostics(); }; - const watcher = new DiagnosticsWatcher( + svelteCheckOptions.onSnapshotCreated = (dirPath: string) => { + watcher.addWatchDirectory(dirPath); + }; + watcher = new DiagnosticsWatcher( opts.workspaceUri, new SvelteCheck(opts.workspaceUri.fsPath, svelteCheckOptions), writer, From 5ca5f125ffc40133a530c40295beac1f32723316 Mon Sep 17 00:00:00 2001 From: Andrew Ewing Date: Thu, 14 Aug 2025 11:39:17 -0700 Subject: [PATCH 5/7] refactor(check): clarify snapshot callback and simplify directory watching; ignore .crush --- .gitignore | 3 + .../plugins/typescript/LSAndTSDocResolver.ts | 12 ++-- packages/language-server/src/svelte-check.ts | 6 +- packages/svelte-check/src/index.ts | 72 ++++++++++++------- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index d64228482..dce9dc14c 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,6 @@ dist # VSCode history extension .history + +# Ignore AI artifacts +.crush/ diff --git a/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts b/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts index c4b7beb29..f390c5b37 100644 --- a/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts +++ b/packages/language-server/src/plugins/typescript/LSAndTSDocResolver.ts @@ -48,9 +48,10 @@ interface LSAndTSDocResolverOptions { nonRecursiveWatchPattern?: string; /** * Optional callback invoked when a new snapshot is created. - * Used by svelte-check to dynamically add parent directories to file watchers. + * Passes the absolute file path of the created snapshot. + * Consumers (like svelte-check) can derive the directory as needed. */ - onSnapshotCreated?: (dirPath: string) => void; + onFileSnapshotCreated?: (filePath: string) => void; } export class LSAndTSDocResolver { @@ -89,13 +90,12 @@ export class LSAndTSDocResolver { this.tsSystem = this.wrapWithPackageJsonMonitoring(this.options?.tsSystem ?? ts.sys); this.globalSnapshotsManager = new GlobalSnapshotsManager(this.tsSystem); // Notify when new snapshots are created so external watchers (svelte-check) - // can add their parent directories dynamically. - if (this.options?.onSnapshotCreated) { + // can react dynamically (for example: add parent directories to file watchers). + if (this.options?.onFileSnapshotCreated) { this.globalSnapshotsManager.onChange((fileName, newDocument) => { if (newDocument) { try { - const dir = dirname(fileName); - this.options?.onSnapshotCreated?.(dir); + this.options?.onFileSnapshotCreated?.(fileName); } catch { // best-effort; ignore errors in callback } diff --git a/packages/language-server/src/svelte-check.ts b/packages/language-server/src/svelte-check.ts index 84a26cec6..00f0d4abb 100644 --- a/packages/language-server/src/svelte-check.ts +++ b/packages/language-server/src/svelte-check.ts @@ -33,9 +33,9 @@ export interface SvelteCheckOptions { watch?: boolean; /** * Optional callback invoked when a new snapshot is created. - * Used by svelte-check to dynamically add watch directories. + * Provides the absolute file path of the snapshot. */ - onSnapshotCreated?: (dirPath: string) => void; + onFileSnapshotCreated?: (filePath: string) => void; } /** @@ -97,7 +97,7 @@ export class SvelteCheck { isSvelteCheck: true, onProjectReloaded: options.onProjectReload, watch: options.watch, - onSnapshotCreated: options.onSnapshotCreated + onFileSnapshotCreated: options.onFileSnapshotCreated } ); this.pluginHost.register( diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 44a163795..9c4022135 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -197,41 +197,64 @@ class DiagnosticsWatcher { this.updateWatchedDirectories(); } + private isSubdir(candidate: string, parent: string) { + const c = path.resolve(candidate); + const p = path.resolve(parent); + return c === p || c.startsWith(p + path.sep); + } + + private minimizeDirs(dirs: string[]): string[] { + const sorted = [...new Set(dirs.map((d) => path.resolve(d)))].sort(); + const result: string[] = []; + for (const dir of sorted) { + if (!result.some((p) => this.isSubdir(dir, p))) { + result.push(dir); + } + } + return result; + } + addWatchDirectory(dir: string) { - if (!dir || this.currentWatchedDirs.has(dir)) { - return; + if (!dir) return; + // Skip if already covered by an existing watched directory + for (const existing of this.currentWatchedDirs) { + if (this.isSubdir(dir, existing)) { + return; + } + } + // If new dir is a parent of existing ones, unwatch children + const toRemove: string[] = []; + for (const existing of this.currentWatchedDirs) { + if (this.isSubdir(existing, dir)) { + toRemove.push(existing); + } + } + if (toRemove.length) { + this.watcher.unwatch(toRemove); + for (const r of toRemove) this.currentWatchedDirs.delete(r); } this.watcher.add(dir); this.currentWatchedDirs.add(dir); - // New files might now be visible; schedule a run - this.scheduleDiagnostics(); } private async updateWatchedDirectories() { const watchDirs = await this.svelteCheck.getWatchDirectories(); - const dirsToWatch = watchDirs || [{ path: this.workspaceUri.fsPath, recursive: true }]; - const newDirs = new Set(dirsToWatch.map((d) => d.path)); + const desired = this.minimizeDirs( + (watchDirs?.map((d) => d.path) || [this.workspaceUri.fsPath]).map((p) => + path.resolve(p) + ) + ); - // Fast diff: find directories to add and remove - const toAdd = [...newDirs].filter((dir) => !this.currentWatchedDirs.has(dir)); - const toRemove = [...this.currentWatchedDirs].filter((dir) => !newDirs.has(dir)); + const current = new Set([...this.currentWatchedDirs].map((p) => path.resolve(p))); + const desiredSet = new Set(desired); - // Add new directories - if (toAdd.length > 0) { - this.watcher.add(toAdd); - } + const toAdd = desired.filter((d) => !current.has(d)); + const toRemove = [...current].filter((d) => !desiredSet.has(d)); - // Remove old directories - if (toRemove.length > 0) { - this.watcher.unwatch(toRemove); - } + if (toAdd.length) this.watcher.add(toAdd); + if (toRemove.length) this.watcher.unwatch(toRemove); - // Update current set - this.currentWatchedDirs = newDirs; - - if (this.ignoreInitialAdd) { - this.scheduleDiagnostics(); - } + this.currentWatchedDirs = new Set(desired); } private async updateDocument(path: string, isNew: boolean) { @@ -319,7 +342,8 @@ parseOptions(async (opts) => { watcher.updateWatchers(); watcher.scheduleDiagnostics(); }; - svelteCheckOptions.onSnapshotCreated = (dirPath: string) => { + svelteCheckOptions.onFileSnapshotCreated = (filePath: string) => { + const dirPath = path.dirname(filePath); watcher.addWatchDirectory(dirPath); }; watcher = new DiagnosticsWatcher( From 6f2c6d09e3b214f8f2be8cd05deeaa123c5222a1 Mon Sep 17 00:00:00 2001 From: Drew Date: Sat, 16 Aug 2025 18:53:10 -0700 Subject: [PATCH 6/7] fix: order-of-operations for diagnostics and watch directories Co-authored-by: Lyu, Wei-Da <36730922+jasonlyu123@users.noreply.github.com> --- packages/svelte-check/src/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 9c4022135..58e770c44 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -194,7 +194,11 @@ class DiagnosticsWatcher { .on('unlink', (path) => this.removeDocument(path)) .on('change', (path) => this.updateDocument(path, false)); - this.updateWatchedDirectories(); + if (this.ignoreInitialAdd) { + getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck).then(() => { + this.updateWatchedDirectories(); + }); + } } private isSubdir(candidate: string, parent: string) { From 59f3b6065c1de0eef604e4e6645942e1831e14b2 Mon Sep 17 00:00:00 2001 From: Drew Date: Sat, 16 Aug 2025 19:16:42 -0700 Subject: [PATCH 7/7] fix: update watch directories before initial diagnostics --- packages/svelte-check/src/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/svelte-check/src/index.ts b/packages/svelte-check/src/index.ts index 58e770c44..aaeffc422 100644 --- a/packages/svelte-check/src/index.ts +++ b/packages/svelte-check/src/index.ts @@ -194,10 +194,9 @@ class DiagnosticsWatcher { .on('unlink', (path) => this.removeDocument(path)) .on('change', (path) => this.updateDocument(path, false)); + this.updateWatchedDirectories(); if (this.ignoreInitialAdd) { - getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck).then(() => { - this.updateWatchedDirectories(); - }); + getDiagnostics(this.workspaceUri, this.writer, this.svelteCheck); } }