export interface PickRemoteSourceOptions { readonly providerLabel?: (provider: RemoteSourceProvider) => string; readonly urlLabel?: string; <ins> readonly providerName?: string; </ins> } export async function pickRemoteSource(model: Model, options: PickRemoteSourceOptions = {}): Promise<string | undefined> { const quickpick = window.createQuickPick<(QuickPickItem & { provider?: RemoteSourceProvider, url?: string })>(); quickpick.ignoreFocusOut = true; <del> const providers = model.getRemoteProviders() .map(provider => ({ label: (provider.icon ? `$(${provider.icon}) ` : '') + (options.providerLabel ? options.providerLabel(provider) : provider.name), alwaysShow: true, provider })); quickpick.placeholder = providers.length === 0 ? localize('provide url', "Provide repository URL") : localize('provide url or pick', "Provide repository URL or pick a repository source."); const updatePicks = (value?: string) => { if (value) { quickpick.items = [{ label: options.urlLabel ?? localize('url', "URL"), description: value, alwaysShow: true, url: value }, ...providers]; } else { quickpick.items = providers; } }; quickpick.onDidChangeValue(updatePicks); updatePicks(); const result = await getQuickPickResult(quickpick); if (result) { if (result.url) { return result.url; } else if (result.provider) { const quickpick = new RemoteSourceProviderQuickPick(result.provider); const remote = await quickpick.pick(); if (remote) { if (typeof remote.url === 'string') { return remote.url; } else if (remote.url.length > 0) { return await window.showQuickPick(remote.url, { ignoreFocusOut: true, placeHolder: localize('pick url', "Choose a URL to clone from.") }); } </del> <ins> const targetedProvider = model.getRemoteProviders().filter(provider => provider.name === options.providerName); if (targetedProvider && targetedProvider.length === 1) { return await pickProviderSource(targetedProvider[0]); } else { const providers = model.getRemoteProviders() .map(provider => ({ label: (provider.icon ? `$(${provider.icon}) ` : '') + (options.providerLabel ? options.providerLabel(provider) : provider.name), alwaysShow: true, provider })); quickpick.placeholder = providers.length === 0 ? localize('provide url', "Provide repository URL") : localize('provide url or pick', "Provide repository URL or pick a repository source."); const updatePicks = (value?: string) => { if (value) { quickpick.items = [{ label: options.urlLabel ?? localize('url', "URL"), description: value, alwaysShow: true, url: value }, ...providers]; } else { quickpick.items = providers; } }; quickpick.onDidChangeValue(updatePicks); updatePicks(); const result = await getQuickPickResult(quickpick); if (result) { if (result.url) { return result.url; } else if (result.provider) { return await pickProviderSource(result.provider); </ins> } } } return undefined; } <ins> async function pickProviderSource(provider: RemoteSourceProvider): Promise<string | undefined> { const quickpick = new RemoteSourceProviderQuickPick(provider); const remote = await quickpick.pick(); if (remote) { if (typeof remote.url === 'string') { return remote.url; } else if (remote.url.length > 0) { return await window.showQuickPick(remote.url, { ignoreFocusOut: true, placeHolder: localize('pick url', "Choose a URL to clone from.") }); } } return undefined; } </ins>