forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Standardize interpreter display format #2540
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
Merged
DonJayamanne
merged 27 commits into
microsoft:master
from
DonJayamanne:standardInterpreterDisplayFormat2
Sep 11, 2018
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
d9706fb
Auto activation of environment in new terminals
DonJayamanne 424a866
refactor
DonJayamanne f4ed816
xxx
DonJayamanne cbbf192
Add method to get path display name
DonJayamanne 0380347
Refactor
DonJayamanne 7347df3
Misc changes
DonJayamanne f5eb358
Minor refactorings
DonJayamanne aa7cba4
refactor
DonJayamanne f9196d3
Fixed tests
DonJayamanne 5ef3621
Renamed test files and fixed some tests
DonJayamanne 9ba5470
Fixed tests
DonJayamanne fe1379a
Fixed more tests
DonJayamanne 979eed7
Fix tests
DonJayamanne 6ee554d
Use Uri to build paths when comparing Uri paths
DonJayamanne bf13254
Fixed tests
DonJayamanne 27fe899
Added tests
DonJayamanne 71f19aa
Add news entry
DonJayamanne 58c6b0d
Revert changes
DonJayamanne 8ef5ccb
Use Uri.fspath to build paths
DonJayamanne bfeea9c
Fixed tests
DonJayamanne bda2ca0
Address code review comments
DonJayamanne 12ce72b
Oops
DonJayamanne 8c61e7c
Improvements
DonJayamanne 2184706
disable cache if file has cannot be calculated
DonJayamanne e02b39f
Perf improvements
DonJayamanne f47451f
Fixed tests
DonJayamanne 7f7379c
Fixed tests
DonJayamanne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improvements to the display format of interpreter information in the list of interpreters. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/client/interpreter/configuration/interpreterComparer.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
'use strict'; | ||
|
||
import { inject, injectable } from 'inversify'; | ||
import { getArchitectureDisplayName } from '../../common/platform/registry'; | ||
import { IInterpreterHelper, PythonInterpreter } from '../contracts'; | ||
import { IInterpreterComparer } from './types'; | ||
|
||
@injectable() | ||
export class InterpreterComparer implements IInterpreterComparer { | ||
constructor(@inject(IInterpreterHelper) private readonly interpreterHelper: IInterpreterHelper) { | ||
} | ||
public compare(a: PythonInterpreter, b: PythonInterpreter): number { | ||
const nameA = this.getSortName(a); | ||
const nameB = this.getSortName(b); | ||
if (nameA === nameB) { | ||
return 0; | ||
} | ||
return nameA > nameB ? 1 : -1; | ||
} | ||
private getSortName(info: PythonInterpreter): string { | ||
const sortNameParts: string[] = []; | ||
const envSuffixParts: string[] = []; | ||
|
||
// Sort order for interpreters is: | ||
// * Version | ||
// * Architecture | ||
// * Interpreter Type | ||
// * Environment name | ||
if (info.version_info && info.version_info.length > 0) { | ||
sortNameParts.push(info.version_info.slice(0, 3).join('.')); | ||
} | ||
if (info.architecture) { | ||
sortNameParts.push(getArchitectureDisplayName(info.architecture)); | ||
} | ||
if (info.companyDisplayName && info.companyDisplayName.length > 0) { | ||
sortNameParts.push(info.companyDisplayName.trim()); | ||
} else { | ||
sortNameParts.push('Python'); | ||
} | ||
|
||
if (info.type) { | ||
const name = this.interpreterHelper.getInterpreterTypeDisplayName(info.type); | ||
if (name) { | ||
envSuffixParts.push(name); | ||
} | ||
} | ||
if (info.envName && info.envName.length > 0) { | ||
envSuffixParts.push(info.envName); | ||
} | ||
|
||
const envSuffix = envSuffixParts.length === 0 ? '' : | ||
`(${envSuffixParts.join(': ')})`; | ||
return `${sortNameParts.join(' ')} ${envSuffix}`.trim(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.