From 7b0838b2f34a37e8fb9c602b6469c8fa508c6520 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Wed, 15 Nov 2017 10:28:39 -0800 Subject: [PATCH] Fixes #56 list all environments (#219) * Fix Microsoft/vscode#37627 (#1368) --- src/client/common/utils.ts | 15 +++++++-------- src/client/interpreter/locators/index.ts | 9 ++++----- tslint.json | 3 ++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/client/common/utils.ts b/src/client/common/utils.ts index 820c81b596da..ae6de92ee7b6 100644 --- a/src/client/common/utils.ts +++ b/src/client/common/utils.ts @@ -413,16 +413,15 @@ export function getWindowsLineEndingCount(document: TextDocument, offset: Number } export function arePathsSame(path1: string, path2: string) { - path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1; - path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2; - return path1.toUpperCase() === path2.toUpperCase(); + path1 = path.normalize(path1); + path2 = path.normalize(path2); + if (IS_WINDOWS) { + return path1.toUpperCase() === path2.toUpperCase(); + } else { + return path1 === path2; + } } -export function areBasePathsSame(path1: string, path2: string) { - path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1; - path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2; - return path.dirname(path1).toUpperCase() === path.dirname(path2).toUpperCase(); -} export async function getInterpreterVersion(pythonPath: string) { return await new Promise((resolve, reject) => { child_process.execFile(pythonPath, ['--version'], (error, stdout, stdErr) => { diff --git a/src/client/interpreter/locators/index.ts b/src/client/interpreter/locators/index.ts index 09ab1c21bc18..198c37f25869 100644 --- a/src/client/interpreter/locators/index.ts +++ b/src/client/interpreter/locators/index.ts @@ -2,9 +2,9 @@ import * as _ from 'lodash'; import { Disposable, Uri, workspace } from 'vscode'; import { RegistryImplementation } from '../../common/registry'; -import { areBasePathsSame, arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils'; +import { arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils'; import { IInterpreterLocatorService, PythonInterpreter } from '../contracts'; -import { IInterpreterVersionService, InterpreterVersionService } from '../interpreterVersion'; +import { InterpreterVersionService } from '../interpreterVersion'; import { VirtualEnvironmentManager } from '../virtualEnvs'; import { fixInterpreterDisplayName, fixInterpreterPath } from './helpers'; import { CondaEnvFileService, getEnvironmentsFile as getCondaEnvFile } from './services/condaEnvFileService'; @@ -46,7 +46,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi } private async getInterpretersPerResource(resource?: Uri) { const locators = this.getLocators(resource); - const promises = locators.map(provider => provider.getInterpreters(resource)); + const promises = locators.map(async provider => provider.getInterpreters(resource)); const listOfInterpreters = await Promise.all(promises); // tslint:disable-next-line:underscore-consistent-invocation @@ -54,8 +54,7 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi .map(fixInterpreterDisplayName) .map(fixInterpreterPath) .reduce((accumulator, current) => { - if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1 && - accumulator.findIndex(item => areBasePathsSame(item.path, current.path)) === -1) { + if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1) { accumulator.push(current); } return accumulator; diff --git a/tslint.json b/tslint.json index 7ff727e68b34..9acc3a190ee9 100644 --- a/tslint.json +++ b/tslint.json @@ -42,6 +42,7 @@ "Thenable", "PromiseLike" ], - "completed-docs": false + "completed-docs": false, + "no-unsafe-any": false } }