From 0e9e031e04edbac21aa939d0959c58bf3f861dbd Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Apr 2023 15:51:58 -0700 Subject: [PATCH 1/3] Add quick pick hover support to explain conda environment lacking a Python interpreter --- package.json | 3 ++- src/client/common/utils/localize.ts | 3 +++ .../commands/setInterpreter.ts | 2 ++ src/client/interpreter/configuration/types.ts | 2 +- .../vscode.proposed.quickPickItemTooltip.d.ts | 16 ++++++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 typings/vscode-proposed/vscode.proposed.quickPickItemTooltip.d.ts diff --git a/package.json b/package.json index 893eb2299abd..9dc606ce4837 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 10c70c8c6cd0..1267cbdf23f4 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -218,6 +218,9 @@ export namespace Interpreters { } export namespace InterpreterQuickPickList { + export const condaEnvWithoutPythonTooltip = l10n.t( + 'Python is not available in this environment, it will be automatically 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..914e35bbfb21 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -415,6 +415,8 @@ 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 = + 'Python is not available in this environment, it will be automatically installed upon selecting it'; } } }); diff --git a/src/client/interpreter/configuration/types.ts b/src/client/interpreter/configuration/types.ts index 90facb7fe640..788a0d33e93b 100644 --- a/src/client/interpreter/configuration/types.ts +++ b/src/client/interpreter/configuration/types.ts @@ -52,7 +52,7 @@ export interface IInterpreterQuickPickItem extends QuickPickItem { interpreter: PythonEnvironment; } -export interface ISpecialQuickPickItem { +export interface ISpecialQuickPickItem extends QuickPickItem { label: string; description?: string; detail?: 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; + } +} From f57fb324aba5797093df8f580f090ac8bf7e0cf6 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Apr 2023 18:19:45 -0700 Subject: [PATCH 2/3] Localize --- src/client/common/utils/localize.ts | 2 +- .../interpreterSelector/commands/setInterpreter.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index 1267cbdf23f4..e680853e6d9c 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -219,7 +219,7 @@ export namespace Interpreters { export namespace InterpreterQuickPickList { export const condaEnvWithoutPythonTooltip = l10n.t( - 'Python is not available in this environment, it will be automatically installed upon selecting it', + '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...'); diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts index 914e35bbfb21..c0876ff518dd 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -415,8 +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 = - 'Python is not available in this environment, it will be automatically installed upon selecting it'; + items[i].tooltip = InterpreterQuickPickList.condaEnvWithoutPythonTooltip; } } }); From e1274134538bb8d87bba4cf61a36ba993b43276b Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 17 Apr 2023 22:32:46 -0700 Subject: [PATCH 3/3] Code review --- src/client/interpreter/configuration/types.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/client/interpreter/configuration/types.ts b/src/client/interpreter/configuration/types.ts index 788a0d33e93b..2f3882e1246e 100644 --- a/src/client/interpreter/configuration/types.ts +++ b/src/client/interpreter/configuration/types.ts @@ -53,10 +53,6 @@ export interface IInterpreterQuickPickItem extends QuickPickItem { } export interface ISpecialQuickPickItem extends QuickPickItem { - label: string; - description?: string; - detail?: string; - alwaysShow: boolean; path?: string; }