diff --git a/extensions/git/package.json b/extensions/git/package.json index 4017a8618ed..874588dd9aa 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -1857,6 +1857,18 @@ "when": "scmProvider == git" } ], + "scm/incomingChanges/context": [ + { + "command": "git.fetchRef", + "group": "1_modification@1", + "when": "scmProvider == git" + }, + { + "command": "git.pullRef", + "group": "1_modification@2", + "when": "scmProvider == git" + } + ], "scm/incomingChanges/allChanges/context": [ { "command": "git.viewAllChanges", @@ -1878,6 +1890,13 @@ "when": "scmProvider == git" } ], + "scm/outgoingChanges/context": [ + { + "command": "git.pushRef", + "group": "1_modification@1", + "when": "scmProvider == git" + } + ], "scm/outgoingChanges/allChanges/context": [ { "command": "git.viewAllChanges", diff --git a/src/vs/platform/actions/common/actions.ts b/src/vs/platform/actions/common/actions.ts index ece50e4de49..0dceffcaaaa 100644 --- a/src/vs/platform/actions/common/actions.ts +++ b/src/vs/platform/actions/common/actions.ts @@ -108,7 +108,9 @@ export class MenuId { static readonly ProblemsPanelContext = new MenuId('ProblemsPanelContext'); static readonly SCMInputBox = new MenuId('SCMInputBox'); static readonly SCMIncomingChanges = new MenuId('SCMIncomingChanges'); + static readonly SCMIncomingChangesContext = new MenuId('SCMIncomingChangesContext'); static readonly SCMOutgoingChanges = new MenuId('SCMOutgoingChanges'); + static readonly SCMOutgoingChangesContext = new MenuId('SCMOutgoingChangesContext'); static readonly SCMIncomingChangesAllChangesContext = new MenuId('SCMIncomingChangesAllChangesContext'); static readonly SCMIncomingChangesHistoryItemContext = new MenuId('SCMIncomingChangesHistoryItemContext'); static readonly SCMOutgoingChangesAllChangesContext = new MenuId('SCMOutgoingChangesAllChangesContext'); diff --git a/src/vs/workbench/contrib/scm/browser/menus.ts b/src/vs/workbench/contrib/scm/browser/menus.ts index 22997f8c9c9..f79b6050a70 100644 --- a/src/vs/workbench/contrib/scm/browser/menus.ts +++ b/src/vs/workbench/contrib/scm/browser/menus.ts @@ -261,17 +261,29 @@ export class SCMHistoryProviderMenus implements ISCMHistoryProviderMenus, IDispo private _incomingHistoryItemGroupMenu: IMenu; get incomingHistoryItemGroupMenu(): IMenu { return this._incomingHistoryItemGroupMenu; } + private _incomingHistoryItemGroupContextMenu: IMenu; + get incomingHistoryItemGroupContextMenu(): IMenu { return this._incomingHistoryItemGroupContextMenu; } + private _outgoingHistoryItemGroupMenu: IMenu; get outgoingHistoryItemGroupMenu(): IMenu { return this._outgoingHistoryItemGroupMenu; } + private _outgoingHistoryItemGroupContextMenu: IMenu; + get outgoingHistoryItemGroupContextMenu(): IMenu { return this._outgoingHistoryItemGroupContextMenu; } + constructor( @IContextKeyService private readonly contextKeyService: IContextKeyService, @IMenuService private readonly menuService: IMenuService) { this._incomingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMIncomingChanges, this.contextKeyService); this.disposables.add(this._incomingHistoryItemGroupMenu); + this._incomingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMIncomingChangesContext, this.contextKeyService); + this.disposables.add(this._incomingHistoryItemGroupContextMenu); + this._outgoingHistoryItemGroupMenu = this.menuService.createMenu(MenuId.SCMOutgoingChanges, this.contextKeyService); this.disposables.add(this._outgoingHistoryItemGroupMenu); + + this._outgoingHistoryItemGroupContextMenu = this.menuService.createMenu(MenuId.SCMOutgoingChangesContext, this.contextKeyService); + this.disposables.add(this._outgoingHistoryItemGroupContextMenu); } getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu { diff --git a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts index 084d36256e7..cb8145f0120 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewPane.ts @@ -3006,11 +3006,13 @@ export class SCMViewPane extends ViewPane { const element = e.element; let context: any = element; let actions: IAction[] = []; + let actionRunner: IActionRunner = new RepositoryPaneActionRunner(() => this.getSelectedResources()); if (isSCMRepository(element)) { const menus = this.scmViewService.menus.getRepositoryMenus(element.provider); const menu = menus.repositoryContextMenu; context = element.provider; + actionRunner = new RepositoryActionRunner(() => this.getSelectedRepositories()); actions = collectContextMenuActions(menu); } else if (isSCMInput(element) || isSCMActionButton(element)) { // noop @@ -3032,11 +3034,18 @@ export class SCMViewPane extends ViewPane { const menu = menus.getResourceFolderMenu(element.context); actions = collectContextMenuActions(menu); } + } else if (isSCMHistoryItemGroupTreeElement(element)) { + const menus = this.scmViewService.menus.getRepositoryMenus(element.repository.provider); + const menu = element.direction === 'incoming' ? + menus.historyProviderMenu?.incomingHistoryItemGroupContextMenu : + menus.historyProviderMenu?.outgoingHistoryItemGroupContextMenu; + + if (menu) { + actionRunner = new HistoryItemGroupActionRunner(); + createAndFillInContextMenuActions(menu, { shouldForwardArgs: true }, actions); + } } - const actionRunner = isSCMRepository(element) ? - new RepositoryActionRunner(() => this.getSelectedRepositories()) : - new RepositoryPaneActionRunner(() => this.getSelectedResources()); actionRunner.onWillRun(() => this.tree.domFocus()); this.contextMenuService.showContextMenu({ diff --git a/src/vs/workbench/contrib/scm/common/history.ts b/src/vs/workbench/contrib/scm/common/history.ts index cd27ba0c3c1..ff86e3693fc 100644 --- a/src/vs/workbench/contrib/scm/common/history.ts +++ b/src/vs/workbench/contrib/scm/common/history.ts @@ -11,7 +11,9 @@ import { ISCMRepository } from 'vs/workbench/contrib/scm/common/scm'; export interface ISCMHistoryProviderMenus { readonly incomingHistoryItemGroupMenu: IMenu; + readonly incomingHistoryItemGroupContextMenu: IMenu; readonly outgoingHistoryItemGroupMenu: IMenu; + readonly outgoingHistoryItemGroupContextMenu: IMenu; getHistoryItemMenu(historyItem: SCMHistoryItemTreeElement): IMenu; } diff --git a/src/vs/workbench/services/actions/common/menusExtensionPoint.ts b/src/vs/workbench/services/actions/common/menusExtensionPoint.ts index d8918e89e62..3a9ff88e5dd 100644 --- a/src/vs/workbench/services/actions/common/menusExtensionPoint.ts +++ b/src/vs/workbench/services/actions/common/menusExtensionPoint.ts @@ -162,12 +162,24 @@ const apiMenus: IAPIMenu[] = [ description: localize('menus.incomingChanges', "The Source Control incoming changes menu"), proposed: 'contribSourceControlHistoryItemGroupMenu' }, + { + key: 'scm/incomingChanges/context', + id: MenuId.SCMIncomingChangesContext, + description: localize('menus.incomingChangesContext', "The Source Control incoming changes context menu"), + proposed: 'contribSourceControlHistoryItemGroupMenu' + }, { key: 'scm/outgoingChanges', id: MenuId.SCMOutgoingChanges, description: localize('menus.outgoingChanges', "The Source Control outgoing changes menu"), proposed: 'contribSourceControlHistoryItemGroupMenu' }, + { + key: 'scm/outgoingChanges/context', + id: MenuId.SCMOutgoingChangesContext, + description: localize('menus.outgoingChangesContext', "The Source Control outgoing changes context menu"), + proposed: 'contribSourceControlHistoryItemGroupMenu' + }, { key: 'scm/incomingChanges/allChanges/context', id: MenuId.SCMIncomingChangesAllChangesContext, diff --git a/src/vscode-dts/vscode.proposed.contribSourceControlHistoryItemGroupMenu.d.ts b/src/vscode-dts/vscode.proposed.contribSourceControlHistoryItemGroupMenu.d.ts index a67c208736e..34315bc14af 100644 --- a/src/vscode-dts/vscode.proposed.contribSourceControlHistoryItemGroupMenu.d.ts +++ b/src/vscode-dts/vscode.proposed.contribSourceControlHistoryItemGroupMenu.d.ts @@ -4,5 +4,7 @@ *--------------------------------------------------------------------------------------------*/ // empty placeholder declaration for the `scm/incomingChanges`-menu contribution point +// empty placeholder declaration for the `scm/incomingChanges/context`-menu contribution point // empty placeholder declaration for the `scm/outgoingChanges`-menu contribution point +// empty placeholder declaration for the `scm/outgoingChanges/context`-menu contribution point // https://github.com/microsoft/vscode/issues/201997