@@ -19,18 +19,22 @@ const buttonClasses = [pinButtonClass, pinnedButtonClass];
19
19
* Shows the quickpick once formatted.
20
20
*/
21
21
export async function showWithPinnedItems ( storageService : IStorageService , storageKey : string , quickPick : IQuickPick < IQuickPickItem > , filterDuplicates ?: boolean ) : Promise < void > {
22
+ const itemsWithoutPinned = quickPick . items ;
23
+ let itemsWithPinned = _formatPinnedItems ( storageKey , quickPick , storageService , undefined , filterDuplicates ) ;
22
24
quickPick . onDidTriggerItemButton ( async buttonEvent => {
23
25
const expectedButton = buttonEvent . button . iconClass && buttonClasses . includes ( buttonEvent . button . iconClass ) ;
24
26
if ( expectedButton ) {
25
- quickPick . items = await _formatPinnedItems ( storageKey , quickPick , storageService , buttonEvent . item , filterDuplicates ) ;
27
+ quickPick . items = itemsWithoutPinned ;
28
+ itemsWithPinned = _formatPinnedItems ( storageKey , quickPick , storageService , buttonEvent . item , filterDuplicates ) ;
29
+ quickPick . items = quickPick . value ? itemsWithoutPinned : itemsWithPinned ;
26
30
}
27
31
} ) ;
28
32
quickPick . onDidChangeValue ( async value => {
29
- // don't show pinned items in the search results
30
- quickPick . items = value ? quickPick . items . filter ( i => i . type !== 'separator' && ! i . buttons ?. find ( b => b . iconClass === pinnedButtonClass ) ) : quickPick . items ;
33
+ // Return pinned items if there is no search value
34
+ quickPick . items = value ? itemsWithoutPinned : itemsWithPinned ;
31
35
} ) ;
32
- quickPick . items = await _formatPinnedItems ( storageKey , quickPick , storageService , undefined , filterDuplicates ) ;
33
- await quickPick . show ( ) ;
36
+ quickPick . items = quickPick . value ? itemsWithoutPinned : itemsWithPinned ;
37
+ quickPick . show ( ) ;
34
38
}
35
39
36
40
function _formatPinnedItems ( storageKey : string , quickPick : IQuickPick < IQuickPickItem > , storageService : IStorageService , changedItem ?: IQuickPickItem , filterDuplicates ?: boolean ) : QuickPickItem [ ] {
0 commit comments