@@ -196,9 +196,9 @@ class FetchAllRemotesItem implements QuickPickItem {
196
196
}
197
197
198
198
class RepositoryItem implements QuickPickItem {
199
- get label ( ) : string {
200
- return `$(repo) ${ this . path } ` ;
201
- }
199
+ get label ( ) : string { return `$(repo) ${ getRepositoryLabel ( this . path ) } ` ; }
200
+
201
+ get description ( ) : string { return this . path ; }
202
202
203
203
constructor ( public readonly path : string ) { }
204
204
}
@@ -358,6 +358,15 @@ function getCheckoutProcessor(repository: Repository, type: string): CheckoutPro
358
358
return undefined ;
359
359
}
360
360
361
+ function getRepositoryLabel ( repositoryRoot : string ) : string {
362
+ const workspaceFolder = workspace . getWorkspaceFolder ( Uri . file ( repositoryRoot ) ) ;
363
+ return workspaceFolder ?. uri . toString ( ) === repositoryRoot ? workspaceFolder . name : path . basename ( repositoryRoot ) ;
364
+ }
365
+
366
+ function compareRepositoryLabel ( repositoryRoot1 : string , repositoryRoot2 : string ) : number {
367
+ return getRepositoryLabel ( repositoryRoot1 ) . localeCompare ( getRepositoryLabel ( repositoryRoot2 ) ) ;
368
+ }
369
+
361
370
function sanitizeBranchName ( name : string , whitespaceChar : string ) : string {
362
371
return name ? name . trim ( ) . replace ( / ^ - + / , '' ) . replace ( / ^ \. | \/ \. | \. \. | ~ | \^ | : | \/ $ | \. l o c k $ | \. l o c k \/ | \\ | \* | \s | ^ \s * $ | \. $ | \[ | \] $ / g, whitespaceChar ) : name ;
363
372
}
@@ -896,7 +905,8 @@ export class CommandCenter {
896
905
897
906
const allRepositoriesLabel = l10n . t ( 'All Repositories' ) ;
898
907
const allRepositoriesQuickPickItem : QuickPickItem = { label : allRepositoriesLabel } ;
899
- const repositoriesQuickPickItems : QuickPickItem [ ] = this . model . closedRepositories . sort ( ) . map ( r => new RepositoryItem ( r ) ) ;
908
+ const repositoriesQuickPickItems : QuickPickItem [ ] = this . model . closedRepositories
909
+ . sort ( compareRepositoryLabel ) . map ( r => new RepositoryItem ( r ) ) ;
900
910
901
911
const items = this . model . closedRepositories . length === 1 ? [ ...repositoriesQuickPickItems ] :
902
912
[ ...repositoriesQuickPickItems , { label : '' , kind : QuickPickItemKind . Separator } , allRepositoriesQuickPickItem ] ;
@@ -3459,7 +3469,8 @@ export class CommandCenter {
3459
3469
3460
3470
const allRepositoriesLabel = l10n . t ( 'All Repositories' ) ;
3461
3471
const allRepositoriesQuickPickItem : QuickPickItem = { label : allRepositoriesLabel } ;
3462
- const repositoriesQuickPickItems : QuickPickItem [ ] = Array . from ( this . model . parentRepositories . keys ( ) ) . sort ( ) . map ( r => new RepositoryItem ( r ) ) ;
3472
+ const repositoriesQuickPickItems : QuickPickItem [ ] = Array . from ( this . model . parentRepositories . keys ( ) )
3473
+ . sort ( compareRepositoryLabel ) . map ( r => new RepositoryItem ( r ) ) ;
3463
3474
3464
3475
const items = this . model . parentRepositories . size === 1 ? [ ...repositoriesQuickPickItems ] :
3465
3476
[ ...repositoriesQuickPickItems , { label : '' , kind : QuickPickItemKind . Separator } , allRepositoriesQuickPickItem ] ;
@@ -3492,7 +3503,8 @@ export class CommandCenter {
3492
3503
3493
3504
const allRepositoriesLabel = l10n . t ( 'All Repositories' ) ;
3494
3505
const allRepositoriesQuickPickItem : QuickPickItem = { label : allRepositoriesLabel } ;
3495
- const repositoriesQuickPickItems : QuickPickItem [ ] = Array . from ( this . model . unsafeRepositories . keys ( ) ) . sort ( ) . map ( r => new RepositoryItem ( r ) ) ;
3506
+ const repositoriesQuickPickItems : QuickPickItem [ ] = Array . from ( this . model . unsafeRepositories . keys ( ) )
3507
+ . sort ( compareRepositoryLabel ) . map ( r => new RepositoryItem ( r ) ) ;
3496
3508
3497
3509
quickpick . items = this . model . unsafeRepositories . size === 1 ? [ ...repositoriesQuickPickItems ] :
3498
3510
[ ...repositoriesQuickPickItems , { label : '' , kind : QuickPickItemKind . Separator } , allRepositoriesQuickPickItem ] ;
0 commit comments