mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3
This commit is contained in:
@@ -6,14 +6,27 @@
|
||||
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IMatch } from 'vs/base/common/filters';
|
||||
import { IItemAccessor } from 'vs/base/common/fuzzyScorer';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
export interface IQuickPickItemHighlights {
|
||||
label?: IMatch[];
|
||||
description?: IMatch[];
|
||||
detail?: IMatch[];
|
||||
}
|
||||
|
||||
export interface IQuickPickItem {
|
||||
type?: 'item';
|
||||
id?: string;
|
||||
label: string;
|
||||
ariaLabel?: string;
|
||||
description?: string;
|
||||
detail?: string;
|
||||
iconClasses?: string[];
|
||||
italic?: boolean;
|
||||
highlights?: IQuickPickItemHighlights;
|
||||
buttons?: IQuickInputButton[];
|
||||
picked?: boolean;
|
||||
alwaysShow?: boolean;
|
||||
@@ -125,7 +138,10 @@ export interface IInputOptions {
|
||||
validateInput?: (input: string) => Promise<string | null | undefined>;
|
||||
}
|
||||
|
||||
export interface IQuickInput {
|
||||
export interface IQuickInput extends IDisposable {
|
||||
|
||||
readonly onDidHide: Event<void>;
|
||||
readonly onDispose: Event<void>;
|
||||
|
||||
title: string | undefined;
|
||||
|
||||
@@ -146,16 +162,20 @@ export interface IQuickInput {
|
||||
show(): void;
|
||||
|
||||
hide(): void;
|
||||
|
||||
onDidHide: Event<void>;
|
||||
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export interface IQuickPick<T extends IQuickPickItem> extends IQuickInput {
|
||||
|
||||
value: string;
|
||||
|
||||
/**
|
||||
* A method that allows to massage the value used
|
||||
* for filtering, e.g, to remove certain parts.
|
||||
*/
|
||||
filterValue: (value: string) => string;
|
||||
|
||||
ariaLabel: string;
|
||||
|
||||
placeholder: string | undefined;
|
||||
|
||||
readonly onDidChangeValue: Event<string>;
|
||||
@@ -254,3 +274,28 @@ export interface IQuickPickItemButtonContext<T extends IQuickPickItem> extends I
|
||||
}
|
||||
|
||||
export type QuickPickInput<T = IQuickPickItem> = T | IQuickPickSeparator;
|
||||
|
||||
|
||||
//region Fuzzy Scorer Support
|
||||
|
||||
export type IQuickPickItemWithResource = IQuickPickItem & { resource: URI | undefined };
|
||||
|
||||
export const quickPickItemScorerAccessor = new class implements IItemAccessor<IQuickPickItemWithResource> {
|
||||
getItemLabel(entry: IQuickPickItemWithResource): string {
|
||||
return entry.label;
|
||||
}
|
||||
|
||||
getItemDescription(entry: IQuickPickItemWithResource): string | undefined {
|
||||
return entry.description;
|
||||
}
|
||||
|
||||
getItemPath(entry: IQuickPickItemWithResource): string | undefined {
|
||||
if (entry.resource?.scheme === Schemas.file) {
|
||||
return entry.resource.fsPath;
|
||||
}
|
||||
|
||||
return entry.resource?.path;
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
Reference in New Issue
Block a user