@@ -262,6 +262,14 @@ class RepositoryItem implements QuickPickItem {
262
262
constructor ( public readonly path : string ) { }
263
263
}
264
264
265
+ class StashItem implements QuickPickItem {
266
+ get label ( ) : string { return `#${ this . stash . index } : ${ this . stash . description } ` ; }
267
+
268
+ get description ( ) : string | undefined { return this . stash . branchName ; }
269
+
270
+ constructor ( readonly stash : Stash ) { }
271
+ }
272
+
265
273
interface ScmCommandOptions {
266
274
repository ?: boolean ;
267
275
diff ?: boolean ;
@@ -3690,17 +3698,15 @@ export class CommandCenter {
3690
3698
}
3691
3699
3692
3700
private async pickStash ( repository : Repository , placeHolder : string ) : Promise < Stash | undefined > {
3693
- const stashes = await repository . getStashes ( ) ;
3694
-
3695
- if ( stashes . length === 0 ) {
3696
- window . showInformationMessage ( l10n . t ( 'There are no stashes in the repository.' ) ) ;
3697
- return ;
3698
- }
3699
-
3700
- const picks = stashes . map ( stash => ( { label : `#${ stash . index } : ${ stash . description } ` , description : stash . branchName , stash } ) ) ;
3701
- const result = await window . showQuickPick ( picks , { placeHolder } ) ;
3701
+ const getStashQuickPickItems = async ( ) : Promise < StashItem [ ] | QuickPickItem [ ] > => {
3702
+ const stashes = await repository . getStashes ( ) ;
3703
+ return stashes . length > 0 ?
3704
+ stashes . map ( stash => new StashItem ( stash ) ) :
3705
+ [ { label : l10n . t ( '$(info) This repository has no stashes.' ) } ] ;
3706
+ } ;
3702
3707
3703
- return result ?. stash ;
3708
+ const result = await window . showQuickPick < StashItem | QuickPickItem > ( getStashQuickPickItems ( ) , { placeHolder } ) ;
3709
+ return result instanceof StashItem ? result . stash : undefined ;
3704
3710
}
3705
3711
3706
3712
private async getStashFromUri ( uri : Uri | undefined ) : Promise < { repository : Repository ; stash : Stash } | undefined > {
0 commit comments