1
>
/*---------------------------------------------------------------------------------------------
quickInput.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { CancellationToken } from '../../../base/common/cancellation.js';
7
>
import { Event } from '../../../base/common/event.js';
8
>
import { createDecorator } from '../../instantiation/common/instantiation.js';
9
>
import { IQuickAccessController } from './quickAccess.js';
10
>
import { IMatch } from '../../../base/common/filters.js';
11
>
import { IItemAccessor } from '../../../base/common/fuzzyScorer.js';
12
>
import { ResolvedKeybinding } from '../../../base/common/keybindings.js';
13
>
import { IDisposable } from '../../../base/common/lifecycle.js';
14
>
import { Schemas } from '../../../base/common/network.js';
15
>
import { IObservable } from '../../../base/common/observable.js';
16
>
import Severity from '../../../base/common/severity.js';
17
>
import { URI } from '../../../base/common/uri.js';
18
>
import { IMarkdownString } from '../../../base/common/htmlContent.js';
19
>
20
>
export interface IQuickItemHighlights {
21
>
label?: IMatch[];
22
>
description?: IMatch[];
23
>
}
24
>
25
>
export interface IQuickPickItemHighlights extends IQuickItemHighlights {
26
>
detail?: IMatch[];
27
>
}
28
>
29
>
export type QuickPickItem = IQuickPickSeparator | IQuickPickItem;
30
>
31
>
/**
32
>
* Base properties for a quick pick and quick tree item.
33
>
*/
34
>
export interface IQuickItem {
35
>
id?: string;
36
>
label: string;
37
>
ariaLabel?: string;
38
>
description?: string;
39
>
/**
40
>
* Whether the item is displayed in italics.
41
>
*/
42
>
italic?: boolean;
43
>
/**
44
>
* Whether the item is displayed with a strikethrough.
45
>
*/
46
>
strikethrough?: boolean;
47
>
/**
48
>
* Icon classes to be passed on as `IIconLabelValueOptions`
49
>
* to the underlying `IconLabel` widget.
50
>
*/
51
>
iconClasses?: readonly string[];
52
>
iconPath?: { dark: URI; light?: URI };
53
>
/**
54
>
* Icon class to be assigned to the quick item container
55
>
* directly.
56
>
*/
57
>
iconClass?: string;
58
>
highlights?: IQuickItemHighlights;
59
>
buttons?: readonly IQuickInputButton[];
60
>
/**
61
>
* Used when we're in multi-select mode. Renders a disabled checkbox.
62
>
*/
63
>
disabled?: boolean;
64
>
}
65
>
66
>
/**
67
>
* Represents a quick pick item used in the quick pick UI.
68
>
*/
69
>
export interface IQuickPickItem extends IQuickItem {
70
>
/**
71
>
* The type of the quick pick item. Used to distinguish between 'item' and 'separator'
72
>
*/
73
>
type?: 'item';
74
>
/**
75
>
* The detail text of the quick pick item. Shown as the second line.
76
>
*/
77
>
detail?: string;
78
>
/**
79
>
* The tooltip for the quick pick item.
80
>
*/
81
>
tooltip?: string | IMarkdownString;
82
>
highlights?: IQuickPickItemHighlights;
83
>
/**
84
>
* Allows to show a keybinding next to the item to indicate
85
>
* how the item can be triggered outside of the picker using
86
>
* keyboard shortcut.
87
>
*/
88
>
keybinding?: ResolvedKeybinding;
89
>
/**
90
>
* Whether the item is picked by default when the Quick Pick is shown.
91
>
*/
92
>
picked?: boolean;
93
>
/**
94
>
* Whether the item is always shown in the Quick Pick regardless of filtering.
95
>
*/
96
>
alwaysShow?: boolean;
97
>
/**
98
>
* Defaults to true with `IQuickPick.canSelectMany`, can be false to disable picks for a single item
99
>
*/
100
>
pickable?: boolean;
101
>
}
102
>
103
>
export interface IQuickPickSeparator {
104
>
/**
105
>
* The type of the quick pick item. Used to distinguish between 'item' and 'separator'
106
>
*/
107
>
type: 'separator';
108
>
id?: string;
109
>
label?: string;
110
>
description?: string;
111
>
ariaLabel?: string;
112
>
buttons?: readonly IQuickInputButton[];
113
>
tooltip?: string | IMarkdownString;
114
>
}
115
>
116
>
export interface IKeyMods {
117
>
readonly ctrlCmd: boolean;
118
>
readonly alt: boolean;
119
>
readonly shift: boolean;
120
>
}
121
>
122
>
export function isKeyModified(keyMods: IKeyMods): boolean {
123
return keyMods.ctrlCmd || keyMods.alt || keyMods.shift;
124
}
126
>
export const NO_KEY_MODS: IKeyMods = { ctrlCmd: false, alt: false, shift: false };
127
>
128
>
export interface IQuickNavigateConfiguration {
129
>
keybindings: readonly ResolvedKeybinding[];
130
>
}
131
>
132
>
export interface IPickOptions<T extends IQuickPickItem> {
133
>
134
>
/**
135
>
* an optional string to show as the title of the quick input
136
>
*/
137
>
title?: string;
138
>
139
>
/**
140
>
* the value to prefill in the input box
141
>
*/
142
>
value?: string;
143
>
144
>
/**
145
>
* an optional string to show as placeholder in the input box to guide the user what she picks on
146
>
*/
147
>
placeHolder?: string;
148
>
149
>
/**
150
>
* the text to display underneath the input box
151
>
*/
152
>
prompt?: string;
153
>
154
>
/**
155
>
* an optional flag to include the description when filtering the picks
156
>
*/
157
>
matchOnDescription?: boolean;
158
>
159
>
/**
160
>
* an optional flag to include the detail when filtering the picks
161
>
*/
162
>
matchOnDetail?: boolean;
163
>
164
>
/**
165
>
* an optional flag to filter the picks based on label. Defaults to true.
166
>
*/
167
>
matchOnLabel?: boolean;
168
>
169
>
/**
170
>
* an optional flag to sort the picks based by the label.
171
>
*/
172
>
sortByLabel?: boolean;
173
>
174
>
/**
175
>
* an optional flag to not close the picker on focus lost
176
>
*/
177
>
ignoreFocusLost?: boolean;
178
>
179
>
/**
180
>
* an optional flag to make this picker multi-select
181
>
*/
182
>
canPickMany?: boolean;
183
>
184
>
/**
185
>
* enables quick navigate in the picker to open an element without typing
186
>
*/
187
>
quickNavigate?: IQuickNavigateConfiguration;
188
>
189
>
/**
190
>
* Hides the input box from the picker UI. This is typically used
191
>
* in combination with quick-navigation where no search UI should
192
>
* be presented.
193
>
*/
194
>
hideInput?: boolean;
195
>
196
>
/**
197
>
* a context key to set when this picker is active
198
>
*/
199
>
contextKey?: string;
200
>
201
>
/**
202
>
* an optional property for the item to focus initially.
203
>
*/
204
>
activeItem?: Promise<T> | T;
205
>
206
>
/**
207
>
* an optional anchor for the picker
208
>
*/
209
>
anchor?: unknown /* HTMLElement */ | { x: number; y: number };
210
>
211
>
/**
212
>
* Placement of the quick input relative to {@link anchor}.
213
>
* `'overlay'` positions the input box directly on top of the anchor (which must be an HTMLElement)
214
>
* and auto-sizes its width to match. Defaults to `'above'`.
215
>
*/
216
>
anchorPosition?: 'above' | 'overlay';
217
>
218
>
onKeyMods?: (keyMods: IKeyMods) => void;
219
>
onDidFocus?: (entry: T) => void;
220
>
onDidTriggerItemButton?: (context: IQuickPickItemButtonContext<T>) => void;
221
>
onDidTriggerSeparatorButton?: (context: IQuickPickSeparatorButtonEvent) => void;
222
>
}
223
>
224
>
export interface IInputOptions {
225
>
226
>
/**
227
>
* an optional string to show as the title of the quick input
228
>
*/
229
>
title?: string;
230
>
231
>
/**
232
>
* the value to prefill in the input box
233
>
*/
234
>
value?: string;
235
>
236
>
/**
237
>
* the selection of value, default to the whole prefilled value
238
>
*/
239
>
valueSelection?: readonly [number, number];
240
>
241
>
/**
242
>
* the text to display underneath the input box
243
>
*/
244
>
prompt?: string;
245
>
246
>
/**
247
>
* an optional string to show as placeholder in the input box to guide the user what to type
248
>
*/
249
>
placeHolder?: string;
250
>
251
>
/**
252
>
* Controls if a password input is shown. Password input hides the typed text.
253
>
*/
254
>
password?: boolean;
255
>
256
>
/**
257
>
* an optional flag to not close the input on focus lost
258
>
*/
259
>
ignoreFocusLost?: boolean;
260
>
261
>
/**
262
>
* an optional function that is used to validate user input.
263
>
*/
264
>
validateInput?: (input: string) => Promise<string | null | undefined | { content: string; severity: Severity }>;
265
>
}
266
>
267
>
export enum QuickInputHideReason {
268
>
269
>
/**
270
>
* Focus moved away from the quick input.
271
>
*/
272
>
Blur = 1,
273
>
274
>
/**
275
>
* An explicit user gesture, e.g. pressing Escape key.
276
>
*/
277
>
Gesture,
278
>
279
>
/**
280
>
* Anything else.
281
>
*/
282
>
Other
283
>
}
284
>
285
>
export interface IQuickInputHideEvent {
286
>
reason: QuickInputHideReason;
287
>
}
288
>
289
>
/**
290
>
* A collection of the different types of QuickInput
291
>
*/
292
>
export const enum QuickInputType {
293
>
QuickPick = 'quickPick',
294
>
InputBox = 'inputBox',
295
>
QuickWidget = 'quickWidget',
296
>
QuickTree = 'quickTree'
297
>
}
298
>
299
>
/**
300
>
* Represents a quick input control that allows users to make selections or provide input quickly.
301
>
*/
302
>
export interface IQuickInput extends IDisposable {
303
>
304
>
/**
305
>
* The type of the quick input.
306
>
*/
307
>
readonly type: QuickInputType;
308
>
309
>
/**
310
>
* An event that is fired when the quick input is hidden.
311
>
*/
312
>
readonly onDidHide: Event<IQuickInputHideEvent>;
313
>
314
>
/**
315
>
* An event that is fired when the quick input will be hidden.
316
>
*/
317
>
readonly onWillHide: Event<IQuickInputHideEvent>;
318
>
319
>
/**
320
>
* An event that is fired when the quick input is disposed.
321
>
*/
322
>
readonly onDispose: Event<void>;
323
>
324
>
/**
325
>
* The title of the quick input.
326
>
*/
327
>
title: string | undefined;
328
>
329
>
/**
330
>
* The description of the quick input. This is rendered right below the input box.
331
>
*/
332
>
description: string | undefined;
333
>
334
>
/**
335
>
* The current step of the quick input rendered in the titlebar.
336
>
*/
337
>
step: number | undefined;
338
>
339
>
/**
340
>
* The total number of steps in the quick input rendered in the titlebar.
341
>
*/
342
>
totalSteps: number | undefined;
343
>
344
>
/**
345
>
* The buttons displayed in the quick input titlebar.
346
>
*/
347
>
buttons: ReadonlyArray<IQuickInputButton>;
348
>
349
>
/**
350
>
* An event that is fired when a button in the quick input is triggered.
351
>
*/
352
>
readonly onDidTriggerButton: Event<IQuickInputButton>;
353
>
354
>
/**
355
>
* Indicates whether the input is enabled.
356
>
*/
357
>
enabled: boolean;
358
>
359
>
/**
360
>
* The context key associated with the quick input.
361
>
*/
362
>
contextKey: string | undefined;
363
>
364
>
/**
365
>
* Indicates whether the quick input is busy. Renders a progress bar if true.
366
>
*/
367
>
busy: boolean;
368
>
369
>
/**
370
>
* Indicates whether the quick input should be hidden when it loses focus.
371
>
*/
372
>
ignoreFocusOut: boolean;
373
>
374
>
/**
375
>
* An optional anchor for the quick input.
376
>
*/
377
>
anchor?: unknown /* HTMLElement */ | { x: number; y: number };
378
>
379
>
/**
380
>
* Placement of the quick input relative to {@link anchor}.
381
>
* `'overlay'` positions the input box directly on top of the anchor (which must be an HTMLElement)
382
>
* and auto-sizes its width to match. Defaults to `'above'`.
383
>
*/
384
>
anchorPosition?: 'above' | 'overlay';
385
>
386
>
/**
387
>
* Shows the quick input.
388
>
*/
389
>
show(): void;
390
>
391
>
/**
392
>
* Hides the quick input.
393
>
*/
394
>
hide(): void;
395
>
396
>
/**
397
>
* Notifies that the quick input has been hidden.
398
>
* @param reason The reason why the quick input was hidden.
399
>
*/
400
>
didHide(reason?: QuickInputHideReason): void;
401
>
402
>
/**
403
>
* Notifies that the quick input will be hidden.
404
>
* @param reason The reason why the quick input will be hidden.
405
>
*/
406
>
willHide(reason?: QuickInputHideReason): void;
407
>
}
408
>
409
>
export interface IQuickWidget extends IQuickInput {
410
>
411
>
/**
412
>
* The type of the quick input.
413
>
*/
414
>
readonly type: QuickInputType.QuickWidget;
415
>
416
>
/**
417
>
* A HTML element that will be rendered inside the quick input.
418
>
*/
419
>
widget: unknown /* HTMLElement */ | undefined;
420
>
}
421
>
422
>
export interface IQuickPickWillAcceptEvent {
423
>
424
>
/**
425
>
* Allows to disable the default accept handling
426
>
* of the picker. If `veto` is called, the picker
427
>
* will not trigger the `onDidAccept` event.
428
>
*/
429
>
veto(): void;
430
>
}
431
>
432
>
export interface IQuickPickDidAcceptEvent {
433
>
434
>
/**
435
>
* Signals if the picker item is to be accepted
436
>
* in the background while keeping the picker open.
437
>
*/
438
>
inBackground: boolean;
439
>
}
440
>
441
>
/**
442
>
* Represents the activation behavior for items in a quick input. This means which item will be
443
>
* "active" (aka focused).
444
>
*/
445
>
export enum ItemActivation {
446
>
/**
447
>
* No item will be active.
448
>
*/
449
>
NONE,
450
>
/**
451
>
* First item will be active.
452
>
*/
453
>
FIRST,
454
>
/**
455
>
* Second item will be active.
456
>
*/
457
>
SECOND,
458
>
/**
459
>
* Last item will be active.
460
>
*/
461
>
LAST
462
>
}
463
>
464
>
/**
465
>
* Represents the focus options for a quick pick.
466
>
*/
467
>
export enum QuickPickFocus {
468
>
/**
469
>
* Focus the first item in the list.
470
>
*/
471
>
First = 1,
472
>
/**
473
>
* Focus the second item in the list.
474
>
*/
475
>
Second,
476
>
/**
477
>
* Focus the last item in the list.
478
>
*/
479
>
Last,
480
>
/**
481
>
* Focus the next item in the list.
482
>
*/
483
>
Next,
484
>
/**
485
>
* Focus the previous item in the list.
486
>
*/
487
>
Previous,
488
>
/**
489
>
* Focus the next page in the list.
490
>
*/
491
>
NextPage,
492
>
/**
493
>
* Focus the previous page in the list.
494
>
*/
495
>
PreviousPage,
496
>
/**
497
>
* Focus the first item under the next separator.
498
>
*/
499
>
NextSeparator,
500
>
/**
501
>
* Focus the first item under the current separator.
502
>
*/
503
>
PreviousSeparator
504
>
}
505
>
506
>
/**
507
>
* Represents a quick pick control that allows the user to select an item from a list of options.
508
>
*/
509
>
export interface IQuickPick<T extends IQuickPickItem, O extends { useSeparators: boolean } = { useSeparators: false }> extends IQuickInput {
510
>
511
>
/**
512
>
* The type of the quick input.
513
>
*/
514
>
readonly type: QuickInputType.QuickPick;
515
>
516
>
/**
517
>
* The current value of the quick pick input.
518
>
*/
519
>
value: string;
520
>
521
>
/**
522
>
* A method that allows to massage the value used for filtering, e.g, to remove certain parts.
523
>
* @param value The value to be filtered.
524
>
* @returns The filtered value.
525
>
*/
526
>
filterValue: (value: string) => string;
527
>
528
>
/**
529
>
* The ARIA label for the quick pick input.
530
>
*/
531
>
ariaLabel: string | undefined;
532
>
533
>
/**
534
>
* The placeholder text for the quick pick input.
535
>
*/
536
>
placeholder: string | undefined;
537
>
538
>
/**
539
>
* Text shown below the quick pick input.
540
>
*/
541
>
prompt: string | undefined;
542
>
543
>
/**
544
>
* An event that is fired when the value of the quick pick input changes.
545
>
*/
546
>
readonly onDidChangeValue: Event<string>;
547
>
548
>
/**
549
>
* An event that is fired when the quick pick is about to accept the selected item.
550
>
*/
551
>
readonly onWillAccept: Event<IQuickPickWillAcceptEvent>;
552
>
553
>
/**
554
>
* An event that is fired when the quick pick has accepted the selected item.
555
>
*/
556
>
readonly onDidAccept: Event<IQuickPickDidAcceptEvent>;
557
>
558
>
/**
559
>
* If enabled, the `onDidAccept` event will be fired when pressing the arrow-right key to accept the selected item without closing the picker.
560
>
*/
561
>
canAcceptInBackground: boolean;
562
>
563
>
/**
564
>
* The OK button state. It can be a boolean value or the string 'default'.
565
>
*/
566
>
ok: boolean | 'default';
567
>
568
>
/**
569
>
* The OK button label.
570
>
*/
571
>
okLabel: string | undefined;
572
>
573
>
/**
574
>
* An event that is fired when the custom button is triggered. The custom button is a button with text rendered to the right of the input.
575
>
*/
576
>
readonly onDidCustom: Event<void>;
577
>
578
>
/**
579
>
* Whether to show the custom button. The custom button is a button with text rendered to the right of the input.
580
>
*/
581
>
customButton: boolean;
582
>
583
>
/**
584
>
* The label for the custom button. The custom button is a button with text rendered to the right of the input.
585
>
*/
586
>
customLabel: string | undefined;
587
>
588
>
/**
589
>
* The hover text for the custom button. The custom button is a button with text rendered to the right of the input.
590
>
*/
591
>
customHover: string | undefined;
592
>
593
>
/**
594
>
* Whether the custom button should be rendered as a secondary button.
595
>
*/
596
>
customButtonSecondary?: boolean;
597
>
598
>
/**
599
>
* An event that is fired when an item button is triggered.
600
>
*/
601
>
readonly onDidTriggerItemButton: Event<IQuickPickItemButtonEvent<T>>;
602
>
603
>
/**
604
>
* An event that is fired when a separator button is triggered.
605
>
*/
606
>
readonly onDidTriggerSeparatorButton: Event<IQuickPickSeparatorButtonEvent>;
607
>
608
>
/**
609
>
* The items to be displayed in the quick pick.
610
>
*/
611
>
items: O extends { useSeparators: true } ? ReadonlyArray<T | IQuickPickSeparator> : ReadonlyArray<T>;
612
>
613
>
/**
614
>
* Whether multiple items can be selected. If so, checkboxes will be rendered.
615
>
*/
616
>
canSelectMany: boolean;
617
>
618
>
/**
619
>
* Whether to match on the description of the items.
620
>
*/
621
>
matchOnDescription: boolean;
622
>
623
>
/**
624
>
* Whether to match on the detail of the items.
625
>
*/
626
>
matchOnDetail: boolean;
627
>
628
>
/**
629
>
* Whether to match on the label of the items.
630
>
*/
631
>
matchOnLabel: boolean;
632
>
633
>
/**
634
>
* The mode to filter the label with. It can be 'fuzzy' or 'contiguous'. Defaults to 'fuzzy'.
635
>
*/
636
>
matchOnLabelMode: 'fuzzy' | 'contiguous';
637
>
638
>
/**
639
>
* Whether to sort the items by label.
640
>
*/
641
>
sortByLabel: boolean;
642
>
643
>
/**
644
>
* Whether to keep the scroll position when the quick pick input is updated.
645
>
*/
646
>
keepScrollPosition: boolean;
647
>
648
>
/**
649
>
* The configuration for quick navigation.
650
>
*/
651
>
quickNavigate: IQuickNavigateConfiguration | undefined;
652
>
653
>
/**
654
>
* The currently active items.
655
>
*/
656
>
activeItems: ReadonlyArray<T>;
657
>
658
>
/**
659
>
* An event that is fired when the active items change.
660
>
*/
661
>
readonly onDidChangeActive: Event<T[]>;
662
>
663
>
/**
664
>
* The item activation behavior for the next time `items` is set. Item activation means which
665
>
* item is "active" (aka focused) when the quick pick is opened or when `items` is set.
666
>
*/
667
>
itemActivation: ItemActivation;
668
>
669
>
/**
670
>
* The currently selected items.
671
>
*/
672
>
selectedItems: ReadonlyArray<T>;
673
>
674
>
/**
675
>
* An event that is fired when the selected items change.
676
>
*/
677
>
readonly onDidChangeSelection: Event<T[]>;
678
>
679
>
/**
680
>
* The key modifiers.
681
>
*/
682
>
readonly keyMods: IKeyMods;
683
>
684
>
/**
685
>
* The selection range for the value in the input.
686
>
*/
687
>
valueSelection: Readonly<[number, number]> | undefined;
688
>
689
>
/**
690
>
* The validation message for the quick pick. This is rendered below the input.
691
>
*/
692
>
validationMessage: string | undefined;
693
>
694
>
/**
695
>
* The severity of the validation message.
696
>
*/
697
>
severity: Severity;
698
>
699
>
/**
700
>
* Checks if the quick pick input has focus.
701
>
* @returns `true` if the quick pick input has focus, `false` otherwise.
702
>
*/
703
>
inputHasFocus(): boolean;
704
>
705
>
/**
706
>
* Focuses on the quick pick input.
707
>
*/
708
>
focusOnInput(): void;
709
>
710
>
/**
711
>
* Hides the input box from the picker UI. This is typically used in combination with quick-navigation where no search UI should be presented.
712
>
*/
713
>
hideInput: boolean;
714
>
715
>
/**
716
>
* Controls whether the count for the items should be shown.
717
>
*/
718
>
hideCountBadge: boolean;
719
>
720
>
/**
721
>
* Whether to hide the "Check All" checkbox.
722
>
*/
723
>
hideCheckAll: boolean;
724
>
725
>
/**
726
>
* Focus a particular item in the list. Used internally for keyboard navigation.
727
>
* @param focus The focus behavior.
728
>
*/
729
>
focus(focus: QuickPickFocus): void;
730
>
731
>
/**
732
>
* Programmatically accepts an item. Used internally for keyboard navigation.
733
>
* @param inBackground Whether you are accepting an item in the background and keeping the picker open.
734
>
*/
735
>
accept(inBackground?: boolean): void;
736
>
}
737
>
738
>
/**
739
>
* Represents an input box in a quick input dialog.
740
>
*/
741
>
export interface IInputBox extends IQuickInput {
742
>
743
>
/**
744
>
* The type of the quick input.
745
>
*/
746
>
readonly type: QuickInputType.InputBox;
747
>
748
>
/**
749
>
* Value shown in the input box.
750
>
*/
751
>
value: string;
752
>
753
>
/**
754
>
* Provide start and end values to be selected in the input box.
755
>
*/
756
>
valueSelection: Readonly<[number, number]> | undefined;
757
>
758
>
/**
759
>
* Value shown as example for input.
760
>
*/
761
>
placeholder: string | undefined;
762
>
763
>
/**
764
>
* Determines if the input value should be hidden while typing.
765
>
*/
766
>
password: boolean;
767
>
768
>
/**
769
>
* Event called when the input value changes.
770
>
*/
771
>
readonly onDidChangeValue: Event<string>;
772
>
773
>
/**
774
>
* Event called when the user submits the input.
775
>
*/
776
>
readonly onDidAccept: Event<void>;
777
>
778
>
/**
779
>
* Text show below the input box.
780
>
*/
781
>
prompt: string | undefined;
782
>
783
>
/**
784
>
* An optional validation message indicating a problem with the current input value.
785
>
* Returning undefined clears the validation message.
786
>
*/
787
>
validationMessage: string | undefined;
788
>
789
>
/**
790
>
* Severity of the input validation message.
791
>
*/
792
>
severity: Severity;
793
>
794
>
/**
795
>
* Programmatically accepts an item. Used internally for keyboard navigation.
796
>
*/
797
>
accept(): void;
798
>
}
799
>
800
>
export enum QuickInputButtonLocation {
801
>
/**
802
>
* In the title bar.
803
>
*/
804
>
Title = 1,
805
>
806
>
/**
807
>
* To the right of the input box.
808
>
*/
809
>
Inline = 2,
810
>
811
>
/**
812
>
* At the far end inside the input box.
813
>
* Used by the public API to create toggles.
814
>
*/
815
>
Input = 3,
816
>
}
817
>
818
>
/**
819
>
* Represents a button in the quick input UI.
820
>
*/
821
>
export interface IQuickInputButton {
822
>
/**
823
>
* The path to the icon for the button.
824
>
* Either `iconPath` or `iconClass` is required.
825
>
*/
826
>
iconPath?: { dark: URI; light?: URI };
827
>
/**
828
>
* The CSS class for the icon of the button.
829
>
* Either `iconPath` or `iconClass` is required.
830
>
*/
831
>
iconClass?: string;
832
>
/**
833
>
* The tooltip text for the button.
834
>
*/
835
>
tooltip?: string;
836
>
/**
837
>
* Whether to always show the button.
838
>
* By default, buttons are only visible when hovering over them with the mouse.
839
>
*/
840
>
alwaysVisible?: boolean;
841
>
/**
842
>
* Where the button should be rendered. The default is {@link QuickInputButtonLocation.Title}.
843
>
* @note This property is ignored if the button was added to a QuickPickItem.
844
>
*/
845
>
location?: QuickInputButtonLocation;
846
>
/**
847
>
* When present, indicates that the button is a toggle button that can be checked or unchecked.
848
>
* The `checked` property indicates the current state of the toggle and will be updated
849
>
* when the button is clicked.
850
>
*/
851
>
readonly toggle?: { checked: boolean };
852
>
/**
853
>
* Optional label for the button. When used with secondary actions, this label appears in the overflow menu.
854
>
*/
855
>
label?: string;
856
>
/**
857
>
* When true, the button will be rendered as a secondary action in the toolbar overflow menu.
858
>
* By default, buttons are rendered as primary actions.
859
>
* @note This does not currently apply to buttons in the Input location
860
>
*/
861
>
secondary?: boolean;
862
>
}
863
>
864
>
export interface IQuickInputButtonWithToggle extends IQuickInputButton {
865
>
readonly toggle: { checked: boolean };
866
>
}
867
>
868
>
/**
869
>
* Represents an event that occurs when a button associated with a quick pick item is clicked.
870
>
* @template T - The type of the quick pick item.
871
>
*/
872
>
export interface IQuickPickItemButtonEvent<T extends IQuickPickItem> {
873
>
/**
874
>
* The button that was clicked.
875
>
*/
876
>
button: IQuickInputButton;
877
>
/**
878
>
* The quick pick item associated with the button.
879
>
*/
880
>
item: T;
881
>
}
882
>
883
>
/**
884
>
* Represents an event that occurs when a separator button is clicked in a quick pick.
885
>
*/
886
>
export interface IQuickPickSeparatorButtonEvent {
887
>
/**
888
>
* The button that was clicked.
889
>
*/
890
>
button: IQuickInputButton;
891
>
/**
892
>
* The separator associated with the button.
893
>
*/
894
>
separator: IQuickPickSeparator;
895
>
}
896
>
897
>
/**
898
>
* Represents a context for a button associated with a quick pick item.
899
>
* @template T - The type of the quick pick item.
900
>
*/
901
>
export interface IQuickPickItemButtonContext<T extends IQuickPickItem> extends IQuickPickItemButtonEvent<T> {
902
>
/**
903
>
* Removes the associated item from the quick pick.
904
>
*/
905
>
removeItem(): void;
906
>
}
907
>
908
>
export type QuickPickInput<T = IQuickPickItem> = T | IQuickPickSeparator;
909
>
910
>
911
>
//#region Fuzzy Scorer Support
912
>
913
>
export type IQuickPickItemWithResource = IQuickPickItem & { resource?: URI };
914
>
915
>
export class QuickPickItemScorerAccessor implements IItemAccessor<IQuickPickItemWithResource> {
916
>
917
>
constructor(private options?: { skipDescription?: boolean; skipPath?: boolean }) { }
918
>
919
>
getItemLabel(entry: IQuickPickItemWithResource): string {
920
return entry.label;
921
}
923
>
getItemDescription(entry: IQuickPickItemWithResource): string | undefined {
924
if (this.options?.skipDescription) {
925
return undefined;