diff --git a/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts b/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts index 88c5c132598c2..3f3bd9c31bcb1 100644 --- a/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts +++ b/src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts @@ -386,6 +386,38 @@ registerAction2(class extends Action2 { }); } + override async run(accessor: ServicesAccessor, historyItem: ISCMHistoryItem, historyItemChange: ISCMHistoryItemChange) { + const editorService = accessor.get(IEditorService); + + if (!historyItem || !historyItemChange.modifiedUri) { + return; + } + + // Open the current (working tree) version of the file, rather than the + // historical snapshot. The historical version is shown when the user + // clicks the row in the graph. + const currentFileUri = URI.file(historyItemChange.modifiedUri.fsPath); + await editorService.openEditor({ resource: currentFileUri }); + } +}); + +registerAction2(class extends Action2 { + constructor() { + super({ + id: 'workbench.scm.action.graph.openFileAtCommit', + title: localize('openFileAtCommit', "Open File at Commit"), + icon: Codicon.history, + f1: false, + menu: [ + { + id: MenuId.SCMHistoryItemChangeContext, + group: '0_view', + order: 2 + } + ] + }); + } + override async run(accessor: ServicesAccessor, historyItem: ISCMHistoryItem, historyItemChange: ISCMHistoryItemChange) { const editorService = accessor.get(IEditorService);