Skip to content

Commit 7b0838b

Browse files
authored
Fixes #56 list all environments (#219)
* Fix microsoft/vscode#37627 (#1368)
1 parent a48959d commit 7b0838b

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/client/common/utils.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -413,16 +413,15 @@ export function getWindowsLineEndingCount(document: TextDocument, offset: Number
413413
}
414414

415415
export function arePathsSame(path1: string, path2: string) {
416-
path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1;
417-
path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2;
418-
return path1.toUpperCase() === path2.toUpperCase();
416+
path1 = path.normalize(path1);
417+
path2 = path.normalize(path2);
418+
if (IS_WINDOWS) {
419+
return path1.toUpperCase() === path2.toUpperCase();
420+
} else {
421+
return path1 === path2;
422+
}
419423
}
420424

421-
export function areBasePathsSame(path1: string, path2: string) {
422-
path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1;
423-
path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2;
424-
return path.dirname(path1).toUpperCase() === path.dirname(path2).toUpperCase();
425-
}
426425
export async function getInterpreterVersion(pythonPath: string) {
427426
return await new Promise<string>((resolve, reject) => {
428427
child_process.execFile(pythonPath, ['--version'], (error, stdout, stdErr) => {

src/client/interpreter/locators/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import * as _ from 'lodash';
33
import { Disposable, Uri, workspace } from 'vscode';
44
import { RegistryImplementation } from '../../common/registry';
5-
import { areBasePathsSame, arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils';
5+
import { arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils';
66
import { IInterpreterLocatorService, PythonInterpreter } from '../contracts';
7-
import { IInterpreterVersionService, InterpreterVersionService } from '../interpreterVersion';
7+
import { InterpreterVersionService } from '../interpreterVersion';
88
import { VirtualEnvironmentManager } from '../virtualEnvs';
99
import { fixInterpreterDisplayName, fixInterpreterPath } from './helpers';
1010
import { CondaEnvFileService, getEnvironmentsFile as getCondaEnvFile } from './services/condaEnvFileService';
@@ -46,16 +46,15 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
4646
}
4747
private async getInterpretersPerResource(resource?: Uri) {
4848
const locators = this.getLocators(resource);
49-
const promises = locators.map(provider => provider.getInterpreters(resource));
49+
const promises = locators.map(async provider => provider.getInterpreters(resource));
5050
const listOfInterpreters = await Promise.all(promises);
5151

5252
// tslint:disable-next-line:underscore-consistent-invocation
5353
return _.flatten(listOfInterpreters)
5454
.map(fixInterpreterDisplayName)
5555
.map(fixInterpreterPath)
5656
.reduce<PythonInterpreter[]>((accumulator, current) => {
57-
if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1 &&
58-
accumulator.findIndex(item => areBasePathsSame(item.path, current.path)) === -1) {
57+
if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1) {
5958
accumulator.push(current);
6059
}
6160
return accumulator;

tslint.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"Thenable",
4343
"PromiseLike"
4444
],
45-
"completed-docs": false
45+
"completed-docs": false,
46+
"no-unsafe-any": false
4647
}
4748
}

0 commit comments

Comments
 (0)