@@ -11,36 +11,50 @@ export function activate (context: vscode.ExtensionContext) {
1111 'http://localhost:3033/snippets/embed-folder'
1212 )
1313
14- const options = data
15- . filter ( i => ! i . isDeleted )
16- . map ( i => {
17- return {
18- label : i . name || '' ,
19- description : `${ i . content [ 0 ] . language } • ${
20- i . folder ?. name || 'Inbox'
21- } `
14+ const options : vscode . QuickPickItem [ ] = [ ]
15+
16+ for ( const snippet of data ) {
17+ if ( snippet . isDeleted ) continue
18+
19+ for ( const fragment of snippet . content ) {
20+ let fragmentLabel = ''
21+ if ( snippet . content . length > 1 ) {
22+ fragmentLabel = fragment . label
2223 }
23- } ) as vscode . QuickPickItem [ ]
24+ options . push ( {
25+ label : `${ snippet . name || '' } ` ,
26+ detail : `${ fragmentLabel } ` ,
27+ description : `${ fragment . language } • ${
28+ snippet . folder ?. name || 'Inbox'
29+ } `
30+ } )
31+ }
32+ }
2433
25- let snippetContent = ''
34+ let fragmentContent = ''
2635
2736 const picked = await vscode . window . showQuickPick ( options , {
2837 placeHolder : 'Type to search...' ,
2938 onDidSelectItem ( item : vscode . QuickPickItem ) {
3039 const snippet = data . find ( i => i . name === item . label )
3140
3241 if ( snippet ) {
33- snippetContent = snippet . content [ 0 ] . value
42+ if ( snippet . content . length === 1 ) {
43+ fragmentContent = snippet . content [ 0 ] . value
44+ } else {
45+ fragmentContent = snippet . content
46+ . find ( i => i . label === item . detail ) ?. value || ''
47+ }
3448 } else {
35- snippetContent = ''
49+ fragmentContent = ''
3650 }
3751 }
3852 } )
3953
4054 if ( ! picked ) return
4155
42- if ( snippetContent . length ) {
43- vscode . env . clipboard . writeText ( snippetContent )
56+ if ( fragmentContent . length ) {
57+ vscode . env . clipboard . writeText ( fragmentContent )
4458 vscode . commands . executeCommand ( 'editor.action.clipboardPasteAction' )
4559 }
4660 } catch ( err ) {
0 commit comments