From 61882f7e78c4bcd9d361cfaa189c87f53ce5325f Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Tue, 18 Apr 2023 08:03:14 -0700 Subject: [PATCH] Add quick pick hover support to explain conda environment lacking a Python interpreter (#21073) Closes https://github.com/microsoft/vscode-python/issues/20786 --- package.json | 3 ++- src/client/common/utils/localize.ts | 3 +++ .../commands/setInterpreter.ts | 1 + src/client/interpreter/configuration/types.ts | 6 +----- .../vscode.proposed.quickPickItemTooltip.d.ts | 16 ++++++++++++++++ 5 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts diff --git a/package.json b/package.json index 62bd7f89b700..60c80693f36e 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "contribEditorContentMenu", "quickPickSortByLabel", "envShellEvent", - "testObserver" + "testObserver", + "quickPickItemTooltip" ], "author": { "name": "Microsoft Corporation" diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index e67aad586764..4c3cd7a45d0d 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -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'); diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts index 9a1d643269ef..c0876ff518dd 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -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; } } }); diff --git a/src/client/interpreter/configuration/types.ts b/src/client/interpreter/configuration/types.ts index 90facb7fe640..2f3882e1246e 100644 --- a/src/client/interpreter/configuration/types.ts +++ b/src/client/interpreter/configuration/types.ts @@ -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; } diff --git a/typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts b/typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts new file mode 100644 index 000000000000..4e7d00fa5edf --- /dev/null +++ b/typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts @@ -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; + } +}