Skip to content

Commit

Permalink
Add quick pick hover support to explain conda environment lacking a P…
Browse files Browse the repository at this point in the history
…ython interpreter (#21073)

Closes #20786
  • Loading branch information
Kartik Raj authored Apr 18, 2023
1 parent 8f8f624 commit 61882f7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"contribEditorContentMenu",
"quickPickSortByLabel",
"envShellEvent",
"testObserver"
"testObserver",
"quickPickItemTooltip"
],
"author": {
"name": "Microsoft Corporation"
Expand Down
3 changes: 3 additions & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ export namespace Interpreters {
}

export namespace InterpreterQuickPickList {
export const condaEnvWithoutPythonTooltip = l10n.t(
'Python is not available in this environment, it will automatically be installed upon selecting it',
);
export const noPythonInstalled = l10n.t('Python is not installed, please download and install it');
export const clickForInstructions = l10n.t('Click for instructions...');
export const globalGroupName = l10n.t('Global');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem
if (isInterpreterQuickPickItem(item) && isProblematicCondaEnvironment(item.interpreter)) {
if (!items[i].label.includes(Octicons.Warning)) {
items[i].label = `${Octicons.Warning} ${items[i].label}`;
items[i].tooltip = InterpreterQuickPickList.condaEnvWithoutPythonTooltip;
}
}
});
Expand Down
6 changes: 1 addition & 5 deletions src/client/interpreter/configuration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ export interface IInterpreterQuickPickItem extends QuickPickItem {
interpreter: PythonEnvironment;
}

export interface ISpecialQuickPickItem {
label: string;
description?: string;
detail?: string;
alwaysShow: boolean;
export interface ISpecialQuickPickItem extends QuickPickItem {
path?: string;
}

Expand Down
16 changes: 16 additions & 0 deletions typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/73904

export interface QuickPickItem {
/**
* An optional flag to sort the final results by index of first query match in label. Defaults to true.
*/
tooltip?: string | MarkdownString;
}
}

0 comments on commit 61882f7

Please sign in to comment.