From 7b26c0c3f55c8ab069961fec720e56a71affe7d5 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Fri, 29 Aug 2025 15:07:11 -0700 Subject: [PATCH 1/3] Warn users about too many files processed in the workspace --- Extension/src/LanguageServer/client.ts | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index 7345b0c78..d255f4f96 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -1723,7 +1723,7 @@ export class DefaultClient implements Client { languageClient = new LanguageClient(`cpptools`, serverOptions, clientOptions); languageClient.onNotification(DebugProtocolNotification, logDebugProtocol); languageClient.onNotification(DebugLogNotification, logLocalized); - languageClient.onNotification(LogTelemetryNotification, (e) => this.logTelemetry(e)); + languageClient.onNotification(LogTelemetryNotification, (e) => void this.logTelemetry(e)); languageClient.onNotification(ShowMessageWindowNotification, showMessageWindow); languageClient.registerProposedFeatures(); await languageClient.start(); @@ -2757,10 +2757,38 @@ export class DefaultClient implements Client { } } - private logTelemetry(notificationBody: TelemetryPayload): void { + private excessiveFilesWarningShown: boolean = false; + private async logTelemetry(notificationBody: TelemetryPayload): Promise { if (notificationBody.event === "includeSquiggles" && this.configurationProvider && notificationBody.properties) { notificationBody.properties["providerId"] = this.configurationProvider; } + + const showExcessiveFilesWarning = new PersistentWorkspaceState('CPP.showExcessiveFilesWarning', true); + if (!this.excessiveFilesWarningShown && notificationBody.event === 'ParsingStats' && showExcessiveFilesWarning.Value) { + const filesDiscovered = notificationBody.metrics?.filesDiscovered ?? 0; + const parsableFiles = notificationBody.metrics?.parsableFiles ?? 0; + if (filesDiscovered > 250000 || parsableFiles > 100000) { + // According to telemetry, less than 3% of workspaces have this many files so it seems like a reasonable threshold. + + const message = localize( + "parsing.stats.large.project", + 'Enumerated {0} files with {1} source files detected. You may want to consider excluding some files for better performance.', + filesDiscovered, + parsableFiles); + const learnMore = localize('learn.more', 'Learn More'); + const dontShowAgain = localize('dont.show.again', 'Don\'t Show Again'); + + // We only want to show this once per session. + this.excessiveFilesWarningShown = true; + const response = await vscode.window.showWarningMessage(message, learnMore, dontShowAgain); + + if (response === dontShowAgain) { + showExcessiveFilesWarning.Value = false; + } else if (response === learnMore) { + void vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://go.microsoft.com/fwlink/?linkid=2333292')); + } + } + } telemetry.logLanguageServerEvent(notificationBody.event, notificationBody.properties, notificationBody.metrics); } From 0dc01ba5d33915b864a846ff7695f9c0e701e637 Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Fri, 29 Aug 2025 15:14:43 -0700 Subject: [PATCH 2/3] tweak --- Extension/src/LanguageServer/client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index d255f4f96..f26dcbe58 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -2772,7 +2772,7 @@ export class DefaultClient implements Client { const message = localize( "parsing.stats.large.project", - 'Enumerated {0} files with {1} source files detected. You may want to consider excluding some files for better performance.', + 'Enumerated {0} files with {1} C/C++ source files detected. You may want to consider excluding some files for better performance.', filesDiscovered, parsableFiles); const learnMore = localize('learn.more', 'Learn More'); @@ -2780,7 +2780,7 @@ export class DefaultClient implements Client { // We only want to show this once per session. this.excessiveFilesWarningShown = true; - const response = await vscode.window.showWarningMessage(message, learnMore, dontShowAgain); + const response = await vscode.window.showInformationMessage(message, learnMore, dontShowAgain); if (response === dontShowAgain) { showExcessiveFilesWarning.Value = false; From 371c0b1643485648c7dc0f633eeec73ea3747a0f Mon Sep 17 00:00:00 2001 From: Bob Brown Date: Fri, 29 Aug 2025 16:56:53 -0700 Subject: [PATCH 3/3] PR feedback --- Extension/src/LanguageServer/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index f26dcbe58..c5a8d96ea 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -2764,7 +2764,7 @@ export class DefaultClient implements Client { } const showExcessiveFilesWarning = new PersistentWorkspaceState('CPP.showExcessiveFilesWarning', true); - if (!this.excessiveFilesWarningShown && notificationBody.event === 'ParsingStats' && showExcessiveFilesWarning.Value) { + if (!this.excessiveFilesWarningShown && showExcessiveFilesWarning.Value && notificationBody.event === 'ParsingStats') { const filesDiscovered = notificationBody.metrics?.filesDiscovered ?? 0; const parsableFiles = notificationBody.metrics?.parsableFiles ?? 0; if (filesDiscovered > 250000 || parsableFiles > 100000) {