8000 Use correct API to get interpreter path for language servers (#20656) · microsoft/vscode-python@377067f · GitHub
[go: up one dir, main page]

Skip to content

Commit 377067f

Browse files
author
Kartik Raj
authored
Use correct API to get interpreter path for language servers (#20656)
For #20644 closes #20657
1 parent cd6ca9d commit 377067f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/client/activation/languageClientMiddlewareBase.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import {
1313
import { ConfigurationItem } from 'vscode-languageserver-protocol';
1414

1515
import { HiddenFilePrefix } from '../common/constants';
16-
import { IConfigurationService } from '../common/types';
1716
import { createDeferred, isThenable } from '../common/utils/async';
1817
import { StopWatch } from '../common/utils/stopWatch';
1918
import { IEnvironmentVariablesProvider } from '../common/variables/types';
19+
import { IInterpreterService } from '../interpreter/contracts';
2020
import { IServiceContainer } from '../ioc/types';
2121
import { EventName } from '../telemetry/constants';
2222
import { LanguageServerType } from './types';
@@ -66,7 +66,7 @@ export class LanguageClientMiddlewareBase implements Middleware {
6666
return next(params, token);
6767
}
6868

69-
const configService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
69+
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
7070
const envService = this.serviceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);
7171

7272
let settings = next(params, token);
@@ -87,9 +87,10 @@ export class LanguageClientMiddlewareBase implements Middleware {
8787
const settingDict: LSPObject & { pythonPath: string; _envPYTHONPATH: string } = settings[
8888
i
8989
] as LSPObject & { pythonPath: string; _envPYTHONPATH: string };
90-
9190
settingDict.pythonPath =
92-
(await this.getPythonPathOverride(uri)) ?? configService.getSettings(uri).pythonPath;
91+
(await this.getPythonPathOverride(uri)) ??
92+
(await interpreterService.getActiveInterpreter(uri))?.path ??
93+
'python';
9394

9495
const env = await envService.getEnvironmentVariables(uri);
9596
const envPYTHONPATH = env.PYTHONPATH;

src/client/interpreter/configuration/pythonPathUpdaterService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { inject, injectable } from 'inversify';
2-
import * as path from 'path';
32
import { ConfigurationTarget, l10n, Uri, window } from 'vscode';
43
import { StopWatch } from '../../common/utils/stopWatch';
54
import { SystemVariables } from '../../common/variables/systemVariables';
@@ -28,7 +27,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage
2827
const pythonPathUpdater = this.getPythonUpdaterService(configTarget, wkspace);
2928
let failed = false;
3029
try {
31-
await pythonPathUpdater.updatePythonPath(pythonPath ? path.normalize(pythonPath) : undefined);
30+
await pythonPathUpdater.updatePythonPath(pythonPath);
3231
} catch (err) {
3332
failed = true;
3433
const reason = err as Error;

0 commit comments

Comments
 (0)
0