diff --git a/src/server/server.ts b/src/server/server.ts index 4c73b002c1896..007b71c1f445d 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -535,7 +535,7 @@ namespace ts.server { hrtime: process.hrtime, logger, canUseEvents, - suppressProjectEvents, + suppressDiagnosticEvents, globalPlugins: options.globalPlugins, pluginProbeLocations: options.pluginProbeLocations, allowLocalPluginLoads: options.allowLocalPluginLoads @@ -951,7 +951,7 @@ namespace ts.server { const useSingleInferredProject = hasArgument("--useSingleInferredProject"); const useInferredProjectPerProjectRoot = hasArgument("--useInferredProjectPerProjectRoot"); const disableAutomaticTypingAcquisition = hasArgument("--disableAutomaticTypingAcquisition"); - const suppressProjectEvents = hasArgument("--suppressProjectEvents"); + const suppressDiagnosticEvents = hasArgument("--suppressDiagnosticEvents"); const telemetryEnabled = hasArgument(Arguments.EnableTelemetry); const options: IoSessionOptions = { diff --git a/src/server/session.ts b/src/server/session.ts index 4989d08794688..a1ccb07c7cae4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -296,7 +296,7 @@ namespace ts.server { canUseEvents: boolean; eventHandler?: ProjectServiceEventHandler; /** Has no effect if eventHandler is also specified. */ - suppressProjectEvents?: boolean; + suppressDiagnosticEvents?: boolean; throttleWaitMilliseconds?: number; globalPlugins?: ReadonlyArray; @@ -320,7 +320,7 @@ namespace ts.server { protected logger: Logger; protected canUseEvents: boolean; - private suppressProjectEvents?: boolean; + private suppressDiagnosticEvents?: boolean; private eventHandler: ProjectServiceEventHandler; constructor(opts: SessionOptions) { @@ -331,7 +331,7 @@ namespace ts.server { this.hrtime = opts.hrtime; this.logger = opts.logger; this.canUseEvents = opts.canUseEvents; - this.suppressProjectEvents = opts.suppressProjectEvents; + this.suppressDiagnosticEvents = opts.suppressDiagnosticEvents; const { throttleWaitMilliseconds } = opts; @@ -371,14 +371,11 @@ namespace ts.server { private defaultEventHandler(event: ProjectServiceEvent) { switch (event.eventName) { case ProjectsUpdatedInBackgroundEvent: - if (this.suppressProjectEvents) { - return; - } const { openFiles } = event.data; this.projectsUpdatedInBackgroundEvent(openFiles); break; case ConfigFileDiagEvent: - if (this.suppressProjectEvents) { + if (this.suppressDiagnosticEvents) { return; } const { triggerFile, configFileName: configFile, diagnostics } = event.data; @@ -390,9 +387,6 @@ namespace ts.server { }, "configFileDiag"); break; case ProjectLanguageServiceStateEvent: { - if (this.suppressProjectEvents) { - return; - } const eventName: protocol.ProjectLanguageServiceStateEventName = "projectLanguageServiceState"; this.event({ projectName: event.data.project.getProjectName(), @@ -414,11 +408,12 @@ namespace ts.server { private projectsUpdatedInBackgroundEvent(openFiles: string[]): void { this.projectService.logger.info(`got projects updated in background, updating diagnostics for ${openFiles}`); if (openFiles.length) { - const checkList = this.createCheckList(openFiles); - - // For now only queue error checking for open files. We can change this to include non open files as well - this.errorCheck.startNew(next => this.updateErrorCheck(next, checkList, 100, /*requireOpen*/ true)); + if (!this.suppressDiagnosticEvents) { + const checkList = this.createCheckList(openFiles); + // For now only queue error checking for open files. We can change this to include non open files as well + this.errorCheck.startNew(next => this.updateErrorCheck(next, checkList, 100, /*requireOpen*/ true)); + } // Send project changed event this.event({ diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5f64bd02ea0d1..b9d22206c0e35 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -7255,6 +7255,8 @@ declare namespace ts.server { */ canUseEvents: boolean; eventHandler?: ProjectServiceEventHandler; + /** Has no effect if eventHandler is also specified. */ + suppressDiagnosticEvents?: boolean; throttleWaitMilliseconds?: number; globalPlugins?: ReadonlyArray; pluginProbeLocations?: ReadonlyArray; @@ -7273,6 +7275,7 @@ declare namespace ts.server { private hrtime; protected logger: Logger; protected canUseEvents: boolean; + private suppressDiagnosticEvents?; private eventHandler; constructor(opts: SessionOptions); private sendRequestCompletedEvent;