diff --git a/src/client/activation/node/languageServerProxy.ts b/src/client/activation/node/languageServerProxy.ts index 777e5b11b5c9..971d128480aa 100644 --- a/src/client/activation/node/languageServerProxy.ts +++ b/src/client/activation/node/languageServerProxy.ts @@ -3,10 +3,16 @@ import '../../common/extensions'; import { inject, injectable } from 'inversify'; -import { Disposable, LanguageClient, LanguageClientOptions } from 'vscode-languageclient'; +import { + DidChangeConfigurationNotification, + Disposable, + LanguageClient, + LanguageClientOptions +} from 'vscode-languageclient'; +import { DeprecatePythonPath } from '../../common/experiments/groups'; import { traceDecorators, traceError } from '../../common/logger'; -import { IConfigurationService, Resource } from '../../common/types'; +import { IConfigurationService, IExperimentsManager, IInterpreterPathService, Resource } from '../../common/types'; import { createDeferred, Deferred, sleep } from '../../common/utils/async'; import { swallowExceptions } from '../../common/utils/decorators'; import { noop } from '../../common/utils/misc'; @@ -32,7 +38,9 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy { @inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory, @inject(ITestManagementService) private readonly testManager: ITestManagementService, @inject(IConfigurationService) private readonly configurationService: IConfigurationService, - @inject(ILanguageServerFolderService) private readonly folderService: ILanguageServerFolderService + @inject(ILanguageServerFolderService) private readonly folderService: ILanguageServerFolderService, + @inject(IExperimentsManager) private readonly experiments: IExperimentsManager, + @inject(IInterpreterPathService) private readonly interpreterPathService: IInterpreterPathService ) { this.startupCompleted = createDeferred(); } @@ -95,6 +103,20 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy { const progressReporting = new ProgressReporting(this.languageClient!); this.disposables.push(progressReporting); + if (this.experiments.inExperiment(DeprecatePythonPath.experiment)) { + this.disposables.push( + this.interpreterPathService.onDidChange(() => { + // Manually send didChangeConfiguration in order to get the server to requery + // the workspace configurations (to then pick up pythonPath set in the middleware). + // This is needed as interpreter changes via the interpreter path service happen + // outside of VS Code's settings (which would mean VS Code sends the config updates itself). + this.languageClient!.sendNotification(DidChangeConfigurationNotification.type, { + settings: null + }); + }) + ); + } + const settings = this.configurationService.getSettings(resource); if (settings.downloadLanguageServer) { this.languageClient.onTelemetry((telemetryEvent) => {