diff --git a/src/vs/platform/quickOpen/common/quickOpen.ts b/src/vs/platform/quickOpen/common/quickOpen.ts index eef2fa91bd5..f7d70839e80 100644 --- a/src/vs/platform/quickOpen/common/quickOpen.ts +++ b/src/vs/platform/quickOpen/common/quickOpen.ts @@ -89,7 +89,7 @@ export interface IPickOptions { /** * an optional flag to make this picker multi-select (honoured by extension API) */ - multiSelect?: boolean; + canSelectMany?: boolean; } export interface IInputOptions { diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 2295b78cdc1..93552cf0e67 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -1528,6 +1528,14 @@ declare module 'vscode' { * A human readable string which is rendered less prominent. */ detail?: string; + + /** + * Optional flag indicating if this item is selected initially. + * (Only honored when the picker allows multiple selections.) + * + * @see [QuickPickOptions.canSelectMany](#QuickPickOptions.canSelectMany) + */ + selected?: boolean; } /** @@ -1555,9 +1563,9 @@ declare module 'vscode' { ignoreFocusOut?: boolean; /** - * An optional flag to make the picker multi-select, if true the result is an array of picks. + * An optional flag to make the picker accept multiple selections, if true the result is an array of picks. */ - multiSelect?: boolean; + canSelectMany?: boolean; /** * An optional function that is invoked whenever an item is selected. @@ -1565,20 +1573,6 @@ declare module 'vscode' { onDidSelectItem?(item: QuickPickItem | string): any; } - /** - * Represents an item that can be selected in a multi-select quick pick UI. - */ - export interface MultiSelectQuickPickItem extends QuickPickItem { - selected?: boolean; - } - - /** - * Options to configure the behavior of the multi-select quick pick UI. (Marker type.) - */ - export interface MultiSelectQuickPickOptions extends QuickPickOptions { - multiSelect: true; - } - /** * Options to configure the behaviour of the [workspace folder](#WorkspaceFolder) pick UI. */ @@ -5080,26 +5074,44 @@ declare module 'vscode' { */ export function showErrorMessage(message: string, options: MessageOptions, ...items: T[]): Thenable; + /** + * Shows a selection list allowing multiple selections. + * + * @param items An array of strings, or a promise that resolves to an array of strings. + * @param options Configures the behavior of the selection list. + * @param token A token that can be used to signal cancellation. + * @return A promise that resolves to the selected items or `undefined`. + */ + export function showQuickPick(items: string[] | Thenable, options: QuickPickOptions & { canSelectMany: true; }, token?: CancellationToken): Thenable; + /** * Shows a selection list. * * @param items An array of strings, or a promise that resolves to an array of strings. * @param options Configures the behavior of the selection list. * @param token A token that can be used to signal cancellation. - * @return A promise that resolves to the selected item(s) or `undefined`. + * @return A promise that resolves to the selection or `undefined`. */ - export function showQuickPick(items: string[] | Thenable, options: MultiSelectQuickPickOptions, token?: CancellationToken): Thenable; export function showQuickPick(items: string[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; + /** + * Shows a selection list allowing multiple selections. + * + * @param items An array of items, or a promise that resolves to an array of items. + * @param options Configures the behavior of the selection list. + * @param token A token that can be used to signal cancellation. + * @return A promise that resolves to the selected items or `undefined`. + */ + export function showQuickPick(items: T[] | Thenable, options: QuickPickOptions & { canSelectMany: true; }, token?: CancellationToken): Thenable; + /** * Shows a selection list. * * @param items An array of items, or a promise that resolves to an array of items. * @param options Configures the behavior of the selection list. * @param token A token that can be used to signal cancellation. - * @return A promise that resolves to the selected item(s) or `undefined`. + * @return A promise that resolves to the selected item or `undefined`. */ - export function showQuickPick(items: T[] | Thenable, options: MultiSelectQuickPickOptions, token?: CancellationToken): Thenable; export function showQuickPick(items: T[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; /** diff --git a/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts b/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts index c2e42dc13b6..a3b4d16d8b5 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts @@ -55,7 +55,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape { }); return asWinJsPromise(token => { - if (options.multiSelect) { + if (options.canSelectMany) { return this._quickInputService.pick(this._contents, options, token) .then(items => { if (items) { diff --git a/src/vs/workbench/api/node/extHostQuickOpen.ts b/src/vs/workbench/api/node/extHostQuickOpen.ts index b95da3ae7b2..832853988d2 100644 --- a/src/vs/workbench/api/node/extHostQuickOpen.ts +++ b/src/vs/workbench/api/node/extHostQuickOpen.ts @@ -7,7 +7,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { wireCancellationToken, asWinJsPromise } from 'vs/base/common/async'; import { CancellationToken } from 'vs/base/common/cancellation'; -import { QuickPickOptions, QuickPickItem, InputBoxOptions, WorkspaceFolderPickOptions, WorkspaceFolder, MultiSelectQuickPickItem, MultiSelectQuickPickOptions } from 'vscode'; +import { QuickPickOptions, QuickPickItem, InputBoxOptions, WorkspaceFolderPickOptions, WorkspaceFolder } from 'vscode'; import { MainContext, MainThreadQuickOpenShape, ExtHostQuickOpenShape, MyQuickPickItems, IMainContext } from './extHost.protocol'; import { ExtHostWorkspace } from 'vs/workbench/api/node/extHostWorkspace'; import { ExtHostCommands } from 'vs/workbench/api/node/extHostCommands'; @@ -29,7 +29,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { this._commands = commands; } - showQuickPick(itemsOrItemsPromise: MultiSelectQuickPickItem[] | Thenable, options: MultiSelectQuickPickOptions, token?: CancellationToken): Thenable; + showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Thenable, options: QuickPickOptions & { canSelectMany: true; }, token?: CancellationToken): Thenable; showQuickPick(itemsOrItemsPromise: string[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; showQuickPick(itemsOrItemsPromise: QuickPickItem[] | Thenable, options?: QuickPickOptions, token?: CancellationToken): Thenable; showQuickPick(itemsOrItemsPromise: Item[] | Thenable, options?: QuickPickOptions, token: CancellationToken = CancellationToken.None): Thenable { @@ -45,7 +45,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { matchOnDescription: options && options.matchOnDescription, matchOnDetail: options && options.matchOnDetail, ignoreFocusLost: options && options.ignoreFocusOut, - multiSelect: options && options.multiSelect + canSelectMany: options && options.canSelectMany }); const promise = TPromise.any([]>[quickPickWidget, itemsPromise]).then(values => { @@ -70,7 +70,7 @@ export class ExtHostQuickOpen implements ExtHostQuickOpenShape { label = item.label; description = item.description; detail = item.detail; - selected = options && options.multiSelect ? (item).selected : undefined; + selected = item.selected; } pickItems.push({ label,