Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct API to get interpreter path for language servers #20656

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/client/activation/languageClientMiddlewareBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import {
import { ConfigurationItem } from 'vscode-languageserver-protocol';

import { HiddenFilePrefix } from '../common/constants';
import { IConfigurationService } from '../common/types';
import { createDeferred, isThenable } from '../common/utils/async';
import { StopWatch } from '../common/utils/stopWatch';
import { IEnvironmentVariablesProvider } from '../common/variables/types';
import { IInterpreterService } from '../interpreter/contracts';
import { IServiceContainer } from '../ioc/types';
import { EventName } from '../telemetry/constants';
import { LanguageServerType } from './types';
Expand Down Expand Up @@ -66,7 +66,7 @@ export class LanguageClientMiddlewareBase implements Middleware {
return next(params, token);
}

const configService = this.serviceContainer.get<IConfigurationService>(IConfigurationService);
const interpreterService = this.serviceContainer.get<IInterpreterService>(IInterpreterService);
const envService = this.serviceContainer.get<IEnvironmentVariablesProvider>(IEnvironmentVariablesProvider);

let settings = next(params, token);
Expand All @@ -87,9 +87,10 @@ export class LanguageClientMiddlewareBase implements Middleware {
const settingDict: LSPObject & { pythonPath: string; _envPYTHONPATH: string } = settings[
i
] as LSPObject & { pythonPath: string; _envPYTHONPATH: string };

settingDict.pythonPath =
(await this.getPythonPathOverride(uri)) ?? configService.getSettings(uri).pythonPath;
(await this.getPythonPathOverride(uri)) ??
(await interpreterService.getActiveInterpreter(uri))?.path ??
'python';

const env = await envService.getEnvironmentVariables(uri);
const envPYTHONPATH = env.PYTHONPATH;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject, injectable } from 'inversify';
import * as path from 'path';
import { ConfigurationTarget, l10n, Uri, window } from 'vscode';
import { StopWatch } from '../../common/utils/stopWatch';
import { SystemVariables } from '../../common/variables/systemVariables';
Expand Down Expand Up @@ -28,7 +27,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage
const pythonPathUpdater = this.getPythonUpdaterService(configTarget, wkspace);
let failed = false;
try {
await pythonPathUpdater.updatePythonPath(pythonPath ? path.normalize(pythonPath) : undefined);
await pythonPathUpdater.updatePythonPath(pythonPath);
} catch (err) {
failed = true;
const reason = err as Error;
Expand Down