@@ -180,17 +180,10 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
180180 private genericRepositoryMenu : IMenu | undefined ;
181181 private contextualRepositoryMenus : Map < string /* contextValue */ , IContextualMenuItem > | undefined ;
182182
183- private readonly resourceGroupMenusItems = new Map < ISCMResourceGroup , SCMMenusItem > ( ) ;
184-
185- private _repositoryContextMenu : IMenu | undefined ;
186- get repositoryContextMenu ( ) : IMenu {
187- if ( ! this . _repositoryContextMenu ) {
188- this . _repositoryContextMenu = this . menuService . createMenu ( MenuId . SCMSourceControl , this . contextKeyService ) ;
189- this . disposables . add ( this . _repositoryContextMenu ) ;
190- }
183+ private genericRepositoryContextMenu : IMenu | undefined ;
184+ private contextualRepositoryContextMenus : Map < string /* contextValue */ , IContextualMenuItem > | undefined ;
191185
192- return this . _repositoryContextMenu ;
193- }
186+ private readonly resourceGroupMenusItems = new Map < ISCMResourceGroup , SCMMenusItem > ( ) ;
194187
195188 private readonly disposables = new DisposableStore ( ) ;
196189
@@ -247,6 +240,38 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
247240 return item . menu ;
248241 }
249242
243+ getRepositoryContextMenu ( repository : ISCMRepository ) : IMenu {
244+ const contextValue = repository . provider . contextValue . get ( ) ;
245+ if ( typeof contextValue === 'undefined' ) {
246+ if ( ! this . genericRepositoryContextMenu ) {
247+ this . genericRepositoryContextMenu = this . menuService . createMenu ( MenuId . SCMSourceControl , this . contextKeyService ) ;
248+ }
249+
250+ return this . genericRepositoryContextMenu ;
251+ }
252+
253+ if ( ! this . contextualRepositoryContextMenus ) {
254+ this . contextualRepositoryContextMenus = new Map < string , IContextualMenuItem > ( ) ;
255+ }
256+
257+ let item = this . contextualRepositoryContextMenus . get ( contextValue ) ;
258+
259+ if ( ! item ) {
260+ const contextKeyService = this . contextKeyService . createOverlay ( [ [ 'scmProviderContext' , contextValue ] ] ) ;
261+ const menu = this . menuService . createMenu ( MenuId . SCMSourceControl , contextKeyService ) ;
262+
263+ item = {
264+ menu, dispose ( ) {
265+ menu . dispose ( ) ;
266+ }
267+ } ;
268+
269+ this . contextualRepositoryContextMenus . set ( contextValue , item ) ;
270+ }
271+
272+ return item . menu ;
273+ }
274+
250275 getResourceGroupMenu ( group : ISCMResourceGroup ) : IMenu {
251276 return this . getOrCreateResourceGroupMenusItem ( group ) . getResourceGroupMenu ( group ) ;
252277 }
0 commit comments