Skip to content

Commit aa4f231

Browse files
authored
Reverted change that ended up considering symlinked interpreters as duplicate interpreter. (#1353)
Fixes #1192
1 parent 8bb6aee commit aa4f231

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

news/2 Fixes/1192.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reverted change that ended up considering symlinked interpreters as duplicate interpreter.

src/client/interpreter/configuration/interpreterSelector.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,9 @@ export class InterpreterSelector implements IInterpreterSelector {
7676

7777
private async removeDuplicates(interpreters: PythonInterpreter[]): Promise<PythonInterpreter[]> {
7878
const result: PythonInterpreter[] = [];
79-
await Promise.all(interpreters.map(async item => item.realPath = await this.fileSystem.getRealPathAsync(item.path)));
8079
interpreters.forEach(x => {
8180
if (result.findIndex(a => a.displayName === x.displayName
82-
&& a.type === x.type && this.fileSystem.arePathsSame(a.realPath!, x.realPath!)) < 0) {
81+
&& a.type === x.type && this.fileSystem.arePathsSame(path.dirname(a.path), path.dirname(x.path))) < 0) {
8382
result.push(x);
8483
}
8584
});

src/client/interpreter/contracts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export type PythonInterpreter = {
6767
envName?: string;
6868
envPath?: string;
6969
cachedEntry?: boolean;
70-
realPath?: string;
7170
};
7271

7372
export type WorkspacePythonPath = {

src/test/configuration/interpreterSelector.test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IServiceContainer } from '../../client/ioc/types';
1515
class InterpreterQuickPickItem implements IInterpreterQuickPickItem {
1616
public path: string;
1717
public label: string;
18-
public description: string;
18+
public description!: string;
1919
public detail?: string;
2020
constructor(l: string, p: string) {
2121
this.path = p;
@@ -24,7 +24,7 @@ class InterpreterQuickPickItem implements IInterpreterQuickPickItem {
2424
}
2525

2626
// tslint:disable-next-line:max-func-body-length
27-
suite('Intepreters - selector', () => {
27+
suite('Interpreters - selector', () => {
2828
let serviceContainer: IServiceContainer;
2929
let workspace: TypeMoq.IMock<IWorkspaceService>;
3030
let appShell: TypeMoq.IMock<IApplicationShell>;
@@ -65,14 +65,14 @@ suite('Intepreters - selector', () => {
6565

6666
test('Suggestions', async () => {
6767
const initial: PythonInterpreter[] = [
68-
{ displayName: '1', path: 'path1', type: InterpreterType.Unknown },
69-
{ displayName: '2', path: 'path1', type: InterpreterType.Unknown },
70-
{ displayName: '1', path: 'path1', type: InterpreterType.Unknown },
71-
{ displayName: '2', path: 'path2', type: InterpreterType.Unknown },
72-
{ displayName: '2', path: 'path2', type: InterpreterType.Unknown },
73-
{ displayName: '2 (virtualenv)', path: 'path2', type: InterpreterType.VirtualEnv },
74-
{ displayName: '3', path: 'path2', type: InterpreterType.Unknown },
75-
{ displayName: '4', path: 'path4', type: InterpreterType.Conda }
68+
{ displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown },
69+
{ displayName: '2', path: 'c:/path1/path1', type: InterpreterType.Unknown },
70+
{ displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown },
71+
{ displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown },
72+
{ displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown },
73+
{ displayName: '2 (virtualenv)', path: 'c:/path2/path2', type: InterpreterType.VirtualEnv },
74+
{ displayName: '3', path: 'c:/path2/path2', type: InterpreterType.Unknown },
75+
{ displayName: '4', path: 'c:/path4/path4', type: InterpreterType.Conda }
7676
];
7777
interpreterService
7878
.setup(x => x.getInterpreters(TypeMoq.It.isAny()))
@@ -82,12 +82,12 @@ suite('Intepreters - selector', () => {
8282
const actual = await selector.getSuggestions();
8383

8484
const expected: InterpreterQuickPickItem[] = [
85-
new InterpreterQuickPickItem('1', 'path1'),
86-
new InterpreterQuickPickItem('2', 'path1'),
87-
new InterpreterQuickPickItem('2', 'path2'),
88-
new InterpreterQuickPickItem('2 (virtualenv)', 'path2'),
89-
new InterpreterQuickPickItem('3', 'path2'),
90-
new InterpreterQuickPickItem('4', 'path4')
85+
new InterpreterQuickPickItem('1', 'c:/path1/path1'),
86+
new InterpreterQuickPickItem('2', 'c:/path1/path1'),
87+
new InterpreterQuickPickItem('2', 'c:/path2/path2'),
88+
new InterpreterQuickPickItem('2 (virtualenv)', 'c:/path2/path2'),
89+
new InterpreterQuickPickItem('3', 'c:/path2/path2'),
90+
new InterpreterQuickPickItem('4', 'c:/path4/path4')
9191
];
9292

9393
assert.equal(actual.length, expected.length, 'Suggestion lengths are different.');

0 commit comments

Comments
 (0)