提交 f114b975 编写于 作者: J Joao Moreno

remove PProgress from QuickInput

related to #53487
上级 11c5b938
......@@ -23,7 +23,7 @@ export interface IQuickNavigateConfiguration {
keybindings: ResolvedKeybinding[];
}
export interface IPickOptions {
export interface IPickOptions<T extends IQuickPickItem> {
/**
* an optional string to show as place holder in the input box to guide the user what she picks on
......@@ -49,6 +49,8 @@ export interface IPickOptions {
* an optional flag to make this picker multi-select
*/
canPickMany?: boolean;
onDidFocus?: (entry: T) => void;
}
export interface IInputOptions {
......@@ -177,7 +179,7 @@ export interface IQuickInputService {
/**
* Opens the quick input box for selecting items and returns a promise with the user selected item(s) if any.
*/
pick<T extends IQuickPickItem, O extends IPickOptions>(picks: TPromise<T[]>, options?: O, token?: CancellationToken): TPromise<O extends { canPickMany: true } ? T[] : T>;
pick<T extends IQuickPickItem, O extends IPickOptions<T>>(picks: TPromise<T[]>, options?: O, token?: CancellationToken): TPromise<O extends { canPickMany: true } ? T[] : T>;
/**
* Opens the quick input box for text input and returns a promise with the user typed value if any.
......
......@@ -38,7 +38,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
public dispose(): void {
}
$show(options: IPickOptions): TPromise<number | number[]> {
$show(options: IPickOptions<TransferQuickPickItems>): TPromise<number | number[]> {
const myToken = ++this._token;
this._contents = new TPromise<TransferQuickPickItems[]>((c, e) => {
......@@ -55,16 +55,21 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
};
});
options = {
...options,
onDidFocus: el => {
if (el) {
this._proxy.$onItemSelected((<TransferQuickPickItems>el).handle);
}
}
};
if (options.canPickMany) {
return asWinJsPromise(token => this._quickInputService.pick(this._contents, options as { canPickMany: true }, token)).then(items => {
if (items) {
return items.map(item => item.handle);
}
return undefined;
}, undefined, progress => {
if (progress) {
this._proxy.$onItemSelected((<TransferQuickPickItems>progress).handle);
}
});
} else {
return asWinJsPromise(token => this._quickInputService.pick(this._contents, options, token)).then(item => {
......@@ -72,10 +77,6 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
return item.handle;
}
return undefined;
}, undefined, progress => {
if (progress) {
this._proxy.$onItemSelected((<TransferQuickPickItems>progress).handle);
}
});
}
}
......
......@@ -402,7 +402,7 @@ export interface TransferInputBox extends BaseTransferQuickInput {
}
export interface MainThreadQuickOpenShape extends IDisposable {
$show(options: IPickOptions): TPromise<number | number[]>;
$show(options: IPickOptions<TransferQuickPickItems>): TPromise<number | number[]>;
$setItems(items: TransferQuickPickItems[]): TPromise<any>;
$setError(error: Error): TPromise<any>;
$input(options: vscode.InputBoxOptions, validateInput: boolean): TPromise<string>;
......
......@@ -891,8 +891,8 @@ export class QuickInputService extends Component implements IQuickInputService {
this.updateStyles();
}
pick<T extends IQuickPickItem, O extends IPickOptions>(picks: TPromise<T[]>, options: O = <O>{}, token: CancellationToken = CancellationToken.None): TPromise<O extends { canPickMany: true } ? T[] : T> {
return new TPromise<O extends { canPickMany: true } ? T[] : T>((resolve, reject, progress) => {
pick<T extends IQuickPickItem, O extends IPickOptions<T>>(picks: TPromise<T[]>, options: O = <O>{}, token: CancellationToken = CancellationToken.None): TPromise<O extends { canPickMany: true } ? T[] : T> {
return new TPromise<O extends { canPickMany: true } ? T[] : T>((resolve, reject) => {
if (token.isCancellationRequested) {
resolve(undefined);
return;
......@@ -914,8 +914,8 @@ export class QuickInputService extends Component implements IQuickInputService {
}),
input.onDidChangeActive(items => {
const focused = items[0];
if (focused) {
progress(focused);
if (focused && options.onDidFocus) {
options.onDidFocus(focused);
}
}),
input.onDidChangeSelection(items => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册