Skip to content

Commit

Permalink
Reverted change that ended up considering symlinked interpreters as d…
Browse files Browse the repository at this point in the history
…uplicate interpreter. (#1353)

Fixes #1192
  • Loading branch information
DonJayamanne authored Apr 10, 2018
1 parent 8bb6aee commit aa4f231
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/1192.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reverted change that ended up considering symlinked interpreters as duplicate interpreter.
3 changes: 1 addition & 2 deletions src/client/interpreter/configuration/interpreterSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ export class InterpreterSelector implements IInterpreterSelector {

private async removeDuplicates(interpreters: PythonInterpreter[]): Promise<PythonInterpreter[]> {
const result: PythonInterpreter[] = [];
await Promise.all(interpreters.map(async item => item.realPath = await this.fileSystem.getRealPathAsync(item.path)));
interpreters.forEach(x => {
if (result.findIndex(a => a.displayName === x.displayName
&& a.type === x.type && this.fileSystem.arePathsSame(a.realPath!, x.realPath!)) < 0) {
&& a.type === x.type && this.fileSystem.arePathsSame(path.dirname(a.path), path.dirname(x.path))) < 0) {
result.push(x);
}
});
Expand Down
1 change: 0 additions & 1 deletion src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export type PythonInterpreter = {
envName?: string;
envPath?: string;
cachedEntry?: boolean;
realPath?: string;
};

export type WorkspacePythonPath = {
Expand Down
32 changes: 16 additions & 16 deletions src/test/configuration/interpreterSelector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IServiceContainer } from '../../client/ioc/types';
class InterpreterQuickPickItem implements IInterpreterQuickPickItem {
public path: string;
public label: string;
public description: string;
public description!: string;
public detail?: string;
constructor(l: string, p: string) {
this.path = p;
Expand All @@ -24,7 +24,7 @@ class InterpreterQuickPickItem implements IInterpreterQuickPickItem {
}

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

test('Suggestions', async () => {
const initial: PythonInterpreter[] = [
{ displayName: '1', path: 'path1', type: InterpreterType.Unknown },
{ displayName: '2', path: 'path1', type: InterpreterType.Unknown },
{ displayName: '1', path: 'path1', type: InterpreterType.Unknown },
{ displayName: '2', path: 'path2', type: InterpreterType.Unknown },
{ displayName: '2', path: 'path2', type: InterpreterType.Unknown },
{ displayName: '2 (virtualenv)', path: 'path2', type: InterpreterType.VirtualEnv },
{ displayName: '3', path: 'path2', type: InterpreterType.Unknown },
{ displayName: '4', path: 'path4', type: InterpreterType.Conda }
{ displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown },
{ displayName: '2', path: 'c:/path1/path1', type: InterpreterType.Unknown },
{ displayName: '1', path: 'c:/path1/path1', type: InterpreterType.Unknown },
{ displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown },
{ displayName: '2', path: 'c:/path2/path2', type: InterpreterType.Unknown },
{ displayName: '2 (virtualenv)', path: 'c:/path2/path2', type: InterpreterType.VirtualEnv },
{ displayName: '3', path: 'c:/path2/path2', type: InterpreterType.Unknown },
{ displayName: '4', path: 'c:/path4/path4', type: InterpreterType.Conda }
];
interpreterService
.setup(x => x.getInterpreters(TypeMoq.It.isAny()))
Expand All @@ -82,12 +82,12 @@ suite('Intepreters - selector', () => {
const actual = await selector.getSuggestions();

const expected: InterpreterQuickPickItem[] = [
new InterpreterQuickPickItem('1', 'path1'),
new InterpreterQuickPickItem('2', 'path1'),
new InterpreterQuickPickItem('2', 'path2'),
new InterpreterQuickPickItem('2 (virtualenv)', 'path2'),
new InterpreterQuickPickItem('3', 'path2'),
new InterpreterQuickPickItem('4', 'path4')
new InterpreterQuickPickItem('1', 'c:/path1/path1'),
new InterpreterQuickPickItem('2', 'c:/path1/path1'),
new InterpreterQuickPickItem('2', 'c:/path2/path2'),
new InterpreterQuickPickItem('2 (virtualenv)', 'c:/path2/path2'),
new InterpreterQuickPickItem('3', 'c:/path2/path2'),
new InterpreterQuickPickItem('4', 'c:/path4/path4')
];

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

0 comments on commit aa4f231

Please sign in to comment.