3
3
import '../../common/extensions' ;
4
4
5
5
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' ;
7
12
13
+ import { DeprecatePythonPath } from '../../common/experiments/groups' ;
8
14
import { traceDecorators , traceError } from '../../common/logger' ;
9
- import { IConfigurationService , Resource } from '../../common/types' ;
15
+ import { IConfigurationService , IExperimentsManager , IInterpreterPathService , Resource } from '../../common/types' ;
10
16
import { createDeferred , Deferred , sleep } from '../../common/utils/async' ;
11
17
import { swallowExceptions } from '../../common/utils/decorators' ;
12
18
import { noop } from '../../common/utils/misc' ;
@@ -32,7 +38,9 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
32
38
@inject ( ILanguageClientFactory ) private readonly factory : ILanguageClientFactory ,
33
39
@inject ( ITestManagementService ) private readonly testManager : ITestManagementService ,
34
40
@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
36
44
) {
37
45
this . startupCompleted = createDeferred < void > ( ) ;
38
46
}
@@ -95,6 +103,20 @@ export class NodeLanguageServerProxy implements ILanguageServerProxy {
95
103
const progressReporting = new ProgressReporting ( this . languageClient ! ) ;
96
104
this . disposables . push ( progressReporting ) ;
97
105
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
+
98
120
const settings = this . configurationService . getSettings ( resource ) ;
99
121
if ( settings . downloadLanguageServer ) {
100
122
this . languageClient . onTelemetry ( ( telemetryEvent ) => {
0 commit comments