mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 09:35:38 -05:00
Merge from vscode 6fded8a497cd0142de3a1c607649a5423a091a25
This commit is contained in:
@@ -25,10 +25,10 @@ import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common
|
||||
|
||||
export interface ICommandQuickPick extends IPickerQuickAccessItem {
|
||||
commandId: string;
|
||||
commandAlias: string | undefined;
|
||||
commandAlias?: string;
|
||||
}
|
||||
|
||||
export interface ICommandsQuickAccessOptions extends IPickerQuickAccessProviderOptions {
|
||||
export interface ICommandsQuickAccessOptions extends IPickerQuickAccessProviderOptions<ICommandQuickPick> {
|
||||
showAlias: boolean;
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ export abstract class AbstractCommandsQuickAccessProvider extends PickerQuickAcc
|
||||
const commandPick = filteredCommandPicks[i];
|
||||
const keybinding = this.keybindingService.lookupKeybinding(commandPick.commandId);
|
||||
const ariaLabel = keybinding ?
|
||||
localize('commandPickAriaLabelWithKeybinding', "{0}, {1}, commands picker", commandPick.label, keybinding.getAriaLabel()) :
|
||||
localize('commandPickAriaLabel', "{0}, commands picker", commandPick.label);
|
||||
localize('commandPickAriaLabelWithKeybinding', "{0}, {1}", commandPick.label, keybinding.getAriaLabel()) :
|
||||
commandPick.label;
|
||||
|
||||
// Separator: recently used
|
||||
if (i === 0 && this.commandsHistory.peek(commandPick.commandId)) {
|
||||
|
||||
@@ -77,7 +77,7 @@ export class HelpQuickAccessProvider implements IQuickAccessProvider {
|
||||
(helpEntry.needsEditor ? editorProviders : globalProviders).push({
|
||||
prefix,
|
||||
label,
|
||||
ariaLabel: localize('entryAriaLabel', "{0}, quick access help picker", label),
|
||||
ariaLabel: localize('helpPickAriaLabel', "{0}, {1}", label, helpEntry.description),
|
||||
description: helpEntry.description
|
||||
});
|
||||
}
|
||||
|
||||
@@ -59,8 +59,17 @@ export interface IPickerQuickAccessItem extends IQuickPickItem {
|
||||
trigger?(buttonIndex: number, keyMods: IKeyMods): TriggerAction | Promise<TriggerAction>;
|
||||
}
|
||||
|
||||
export interface IPickerQuickAccessProviderOptions {
|
||||
export interface IPickerQuickAccessProviderOptions<T extends IPickerQuickAccessItem> {
|
||||
|
||||
/**
|
||||
* Enables support for opening picks in the background via gesture.
|
||||
*/
|
||||
canAcceptInBackground?: boolean;
|
||||
|
||||
/**
|
||||
* Enables to show a pick entry when no results are returned from a search.
|
||||
*/
|
||||
noResultsPick?: T;
|
||||
}
|
||||
|
||||
export type Pick<T> = T | IQuickPickSeparator;
|
||||
@@ -85,7 +94,7 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
|
||||
|
||||
private static FAST_PICKS_RACE_DELAY = 200; // timeout before we accept fast results before slow results are present
|
||||
|
||||
constructor(private prefix: string, protected options?: IPickerQuickAccessProviderOptions) {
|
||||
constructor(private prefix: string, protected options?: IPickerQuickAccessProviderOptions<T>) {
|
||||
super();
|
||||
}
|
||||
|
||||
@@ -113,9 +122,10 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
|
||||
|
||||
// Collect picks and support both long running and short or combined
|
||||
const picksToken = picksCts.token;
|
||||
const providedPicks = this.getPicks(picker.value.substr(this.prefix.length).trim(), picksDisposables, picksToken);
|
||||
const picksFilter = picker.value.substr(this.prefix.length).trim();
|
||||
const providedPicks = this.getPicks(picksFilter, picksDisposables, picksToken);
|
||||
|
||||
function applyPicks(picks: Picks<T>, skipEmpty?: boolean): boolean {
|
||||
const applyPicks = (picks: Picks<T>, skipEmpty?: boolean): boolean => {
|
||||
let items: ReadonlyArray<Pick<T>>;
|
||||
let activeItem: T | undefined = undefined;
|
||||
|
||||
@@ -126,8 +136,14 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
|
||||
items = picks;
|
||||
}
|
||||
|
||||
if (items.length === 0 && skipEmpty) {
|
||||
return false;
|
||||
if (items.length === 0) {
|
||||
if (skipEmpty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (picksFilter.length > 0 && this.options?.noResultsPick) {
|
||||
items = [this.options.noResultsPick];
|
||||
}
|
||||
}
|
||||
|
||||
picker.items = items;
|
||||
@@ -136,7 +152,7 @@ export abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// No Picks
|
||||
if (providedPicks === null) {
|
||||
|
||||
@@ -90,9 +90,14 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
|
||||
picker.placeholder = descriptor?.placeholder;
|
||||
picker.quickNavigate = options?.quickNavigateConfiguration;
|
||||
picker.hideInput = !!picker.quickNavigate && !visibleQuickAccess; // only hide input if there was no picker opened already
|
||||
picker.itemActivation = options?.itemActivation || (options?.quickNavigateConfiguration ? ItemActivation.SECOND : ItemActivation.FIRST);
|
||||
if (typeof options?.itemActivation === 'number' || options?.quickNavigateConfiguration) {
|
||||
picker.itemActivation = options?.itemActivation ?? ItemActivation.SECOND /* quick nav is always second */;
|
||||
}
|
||||
picker.contextKey = descriptor?.contextKey;
|
||||
picker.filterValue = (value: string) => value.substring(descriptor ? descriptor.prefix.length : 0);
|
||||
if (descriptor?.placeholder) {
|
||||
picker.ariaLabel = descriptor?.placeholder;
|
||||
}
|
||||
|
||||
// Register listeners
|
||||
const cancellationToken = this.registerPickerListeners(picker, provider, descriptor, value, disposables);
|
||||
|
||||
Reference in New Issue
Block a user