Skip to content

Commit ec62819

Browse files
author
Kartik Raj
authored
Add support for dynamic updates in interpreter list (#17043)
* Add support for dynamic updates in interpreter list * News entry * Cleanup * Add implementation to preserve scroll position * Fix * Refactor code nicely * Cleanup * Fix some bugs and tests * Fix more tests and bugs * Fix linting * Move private methods to where they are used * Ensure we set partial display names * Fix unit tests * Fix comment * Ensure special active items are also maintained * Ensure we set recommended item after refresh finishes * Add doc comment * Code reviews * Code reviews II
1 parent a62bd99 commit ec62819

30 files changed

Lines changed: 438 additions & 224 deletions

File tree

news/1 Enhancements/17043.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for dynamic updates in interpreter list.

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"Interpreters.RefreshingInterpreters": "Refreshing Python Interpreters",
5050
"Interpreters.entireWorkspace": "Entire workspace",
5151
"Interpreters.pythonInterpreterPath": "Python interpreter path: {0}",
52-
"Interpreters.LoadingInterpreters": "Loading Python Interpreters",
52+
"Interpreters.DiscoveringInterpreters": "Discovering Python Interpreters",
5353
"Interpreters.condaInheritEnvMessage": "We noticed you're using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we recommend that you let the Python extension change \"terminal.integrated.inheritEnv\" to false in your user settings.",
5454
"Logging.CurrentWorkingDirectory": "cwd:",
5555
"InterpreterQuickPickList.quickPickListPlaceholder": "Current: {0}",

package.nls.nl.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"LanguageService.lsFailedToDownload": "We zijn een probleem tegengekomen bij het downloaden van de language server. Aan het terugschakelen naar het alternatief, Jedi. Bekijk het weergavepaneel voor details.",
2424
"LanguageService.lsFailedToExtract": "We zijn een probleem tegengekomen bij het uitpakken van de language server. Aan het terugschakelen naar het alternatief, Jedi. Bekijk het weergavepaneel voor details.",
2525
"Interpreters.RefreshingInterpreters": "Python-Interpreters verversen",
26-
"Interpreters.LoadingInterpreters": "Python-Interpreters laden",
2726
"Linter.InstalledButNotEnabled": "Linter {0} is geinstalleerd maar niet ingeschakeld.",
2827
"Linter.replaceWithSelectedLinter": "Meerdere linters zijn ingeschakeld in de instellingen. Vervangen met '{0}'?",
2928
"diagnostics.warnSourceMaps": "Bronkaartondersteuning is ingeschakeld in de Python-extensie, dit zal een ongunstige impact hebben op de uitvoering van de extensie.",

package.nls.zh-cn.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"Interpreters.RefreshingInterpreters": "正在刷新 Python 解释器",
4949
"Interpreters.entireWorkspace": "完整工作区",
5050
"Interpreters.pythonInterpreterPath": "Python 解释器路径: {0}",
51-
"Interpreters.LoadingInterpreters": "正在加载 Python 解释器",
5251
"Interpreters.condaInheritEnvMessage": "您正在使用 conda 环境,如果您在集成终端中遇到相关问题,建议您允许 Python 扩展将用户设置中的 \"terminal.integrated.inheritEnv\" 改为 false。",
5352
"Logging.CurrentWorkingDirectory": "cwd:",
5453
"InterpreterQuickPickList.quickPickListPlaceholder": "当前: {0}",

package.nls.zh-tw.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"LanguageService.lsFailedToExtract": "擷取語言伺服器時遇到問題。改回使用替代方案 \"Jedi\"。請檢查 Python 輸出面板以取得更多資訊。",
3232
"Experiments.inGroup": "使用者屬於 \"{0}\" 實驗性群組",
3333
"Interpreters.RefreshingInterpreters": "正在重新整理 Python 解譯器",
34-
"Interpreters.LoadingInterpreters": "正在載入 Python 解譯器",
3534
"Interpreters.condaInheritEnvMessage": "我們發覺到您在使用 conda 環境。如果你在整合式終端器中使用這個環境時遇到問題,建議您讓 Python 延伸模組變更使用者設定中的 \"terminal.integrated.inheritEnv\" 為 false。",
3635
"Logging.CurrentWorkingDirectory": "cwd:",
3736
"Common.doNotShowAgain": "不再顯示",

src/client/common/utils/async.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class DeferredImpl<T> implements Deferred<T> {
7777
}
7878

7979
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
80-
export function createDeferred<T>(scope: any = null): Deferred<T> {
80+
export function createDeferred<T = void>(scope: any = null): Deferred<T> {
8181
return new DeferredImpl<T>(scope);
8282
}
8383

src/client/common/utils/localize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ export namespace Experiments {
261261
export const optedOutOf = localize('Experiments.optedOutOf', "User opted out of experiment group '{0}'");
262262
}
263263
export namespace Interpreters {
264-
export const loading = localize('Interpreters.LoadingInterpreters', 'Loading Python Interpreters');
264+
export const discovering = localize('Interpreters.DiscoveringInterpreters', 'Discovering Python Interpreters');
265265
export const refreshing = localize('Interpreters.RefreshingInterpreters', 'Refreshing Python Interpreters');
266266
export const condaInheritEnvMessage = localize(
267267
'Interpreters.condaInheritEnvMessage',

src/client/common/utils/multiStepInput.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'use strict';
77

88
import { inject, injectable } from 'inversify';
9-
import { Disposable, QuickInput, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItem } from 'vscode';
9+
import { Disposable, QuickInput, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItem, Event } from 'vscode';
1010
import { IApplicationShell } from '../application/types';
1111

1212
// Borrowed from https://github.com/Microsoft/vscode-extension-samples/blob/master/quickinput-sample/src/multiStepInput.ts
@@ -39,7 +39,8 @@ type QuickInputButtonSetup = {
3939
*/
4040
callback: buttonCallbackType<QuickPickItem>;
4141
};
42-
export interface IQuickPickParameters<T extends QuickPickItem> {
42+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
43+
export interface IQuickPickParameters<T extends QuickPickItem, E = any> {
4344
title?: string;
4445
step?: number;
4546
totalSteps?: number;
@@ -50,7 +51,13 @@ export interface IQuickPickParameters<T extends QuickPickItem> {
5051
customButtonSetup?: QuickInputButtonSetup;
5152
matchOnDescription?: boolean;
5253
matchOnDetail?: boolean;
54+
keepScrollPosition?: boolean;
55+
sortByLabel?: boolean;
5356
acceptFilterBoxTextAsSelection?: boolean;
57+
onChangeItem?: {
58+
callback: (event: E, quickPick: QuickPick<T>) => Promise<void>;
59+
event: Event<E>;
60+
};
5461
}
5562

5663
interface InputBoxParameters {
@@ -110,13 +117,18 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
110117
matchOnDescription,
111118
matchOnDetail,
112119
acceptFilterBoxTextAsSelection,
120+
onChangeItem,
121+
keepScrollPosition,
122+
sortByLabel,
113123
}: P): Promise<MultiStepInputQuickPicResponseType<T, P>> {
114124
const disposables: Disposable[] = [];
115125
try {
116126
return await new Promise<MultiStepInputQuickPicResponseType<T, P>>((resolve, reject) => {
117127
const input = this.shell.createQuickPick<T>();
118128
input.title = title;
119129
input.step = step;
130+
input.keepScrollPosition = keepScrollPosition;
131+
input.sortByLabel = sortByLabel || false;
120132
input.totalSteps = totalSteps;
121133
input.placeholder = placeholder;
122134
input.ignoreFocusOut = true;
@@ -160,6 +172,9 @@ export class MultiStepInput<S> implements IMultiStepInput<S> {
160172
this.current.dispose();
161173
}
162174
this.current = input;
175+
if (onChangeItem) {
176+
disposables.push(onChangeItem.event((e) => onChangeItem.callback(e, input)));
177+
}
163178
this.current.show();
164179
});
165180
} finally {

0 commit comments

Comments
 (0)