Skip to content

Commit 1cd6bb7

Browse files
authored
Manually send didConfigurationChange on interpreter change (#12366)
1 parent 9727138 commit 1cd6bb7

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

src/client/activation/node/languageServerProxy.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
import '../../common/extensions';
44

55
import { inject, injectable } from 'inversify';
6-
import { Disposable, LanguageClient, LanguageClientOptions } from 'vscode-languageclient';
6+
import {
7+
DidChangeConfigurationNotification,
8+
Disposable,
9+
LanguageClient,
10+
LanguageClientOptions
11+
} from 'vscode-languageclient';
712

13+
import { DeprecatePythonPath } from '../../common/experiments/groups';
814
import { traceDecorators, traceError } from '../../common/logger';
9-
import { IConfigurationService, Resource } from '../../common/types';
15+
import { IConfigurationService, IExperimentsManager, IInterpreterPathService, Resource } from '../../common/types';
1016
import { createDeferred, Deferred, sleep } from '../../common/utils/async';
1117
import { swallowExceptions } from '../../common/utils/decorators';
1218
import { noop } from '../../common/utils/misc';
@@ -32,7 +38,9 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
3238
@inject(ILanguageClientFactory) private readonly factory: ILanguageClientFactory,
3339
@inject(ITestManagementService) private readonly testManager: ITestManagementService,
3440
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
35-
@inject(ILanguageServerFolderService) private readonly folderService: ILanguageServerFolderService
41+
@inject(ILanguageServerFolderService) private readonly folderService: ILanguageServerFolderService,
42+
@inject(IExperimentsManager) private readonly experiments: IExperimentsManager,
43+
@inject(IInterpreterPathService) private readonly interpreterPathService: IInterpreterPathService
3644
) {
3745
this.startupCompleted = createDeferred<void>();
3846
}
@@ -95,6 +103,20 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
95103
const progressReporting = new ProgressReporting(this.languageClient!);
96104
this.disposables.push(progressReporting);
97105

106+
if (this.experiments.inExperiment(DeprecatePythonPath.experiment)) {
107+
this.disposables.push(
108+
this.interpreterPathService.onDidChange(() => {
109+
// Manually send didChangeConfiguration in order to get the server to requery
110+
// the workspace configurations (to then pick up pythonPath set in the middleware).
111+
// This is needed as interpreter changes via the interpreter path service happen
112+
// outside of VS Code's settings (which would mean VS Code sends the config updates itself).
113+
this.languageClient!.sendNotification(DidChangeConfigurationNotification.type, {
114+
settings: null
115+
});
116+
})
117+
);
118+
}
119+
98120
const settings = this.configurationService.getSettings(resource);
99121
if (settings.downloadLanguageServer) {
100122
this.languageClient.onTelemetry((telemetryEvent) => {

0 commit comments

Comments
 (0)