@@ -6,15 +6,18 @@ import SnippetsStorage from "./snippetsStorage";
66import languages from "./languages" ;
77
88function quickPickCustom (
9- items : vscode . QuickPickItem [ ]
9+ items : vscode . QuickPickItem [ ] ,
10+ clearActiveItems = true
1011) : Promise < string | vscode . QuickPickItem > {
1112 return new Promise ( ( resolve ) => {
1213 const quickPick = vscode . window . createQuickPick ( ) ;
1314 quickPick . title = 'Enter keywords for snippet search (e.g. "read file")' ;
1415 quickPick . items = items ;
1516
1617 quickPick . onDidChangeValue ( ( ) => {
17- quickPick . activeItems = [ ] ;
18+ if ( clearActiveItems ) {
19+ quickPick . activeItems = [ ] ;
20+ }
1821 } ) ;
1922
2023 quickPick . onDidAccept ( ( ) => {
@@ -38,7 +41,8 @@ export interface QueryResult {
3841
3942export async function query (
4043 language : string ,
41- snippetsStorage : SnippetsStorage
44+ snippetsStorage : SnippetsStorage ,
45+ suggestOnlySaved = false
4246) : Promise < QueryResult > {
4347 const suggestions = new Set (
4448 cache . state . get < string [ ] > ( `snippet_suggestions_${ language } ` , [ ] )
@@ -58,15 +62,20 @@ export async function query(
5862 }
5963 }
6064
61- for ( const suggestion of suggestions ) {
62- const tempQuickItem : vscode . QuickPickItem = {
63- label : suggestion ,
64- description : "" ,
65- } ;
66- suggestionsQuickItems . push ( tempQuickItem ) ;
65+ if ( ! suggestOnlySaved ) {
66+ for ( const suggestion of suggestions ) {
67+ const tempQuickItem : vscode . QuickPickItem = {
68+ label : suggestion ,
69+ description : "" ,
70+ } ;
71+ suggestionsQuickItems . push ( tempQuickItem ) ;
72+ }
6773 }
6874
69- const selectedItem = await quickPickCustom ( suggestionsQuickItems ) ;
75+ const selectedItem = await quickPickCustom (
76+ suggestionsQuickItems ,
77+ ! suggestOnlySaved
78+ ) ;
7079 const input =
7180 typeof selectedItem === "string" ? selectedItem : selectedItem . label ;
7281 const savedSnippetContent =
0 commit comments