diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index f8d810d42..9b1cd57ba 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -1744,7 +1744,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(); @@ -2778,10 +2778,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 && showExcessiveFilesWarning.Value && notificationBody.event === 'ParsingStats') { + 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} 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'); + 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.showInformationMessage(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); }