@@ -82,6 +82,20 @@ const commandSwitchToCommit = async (commitItemOrSha?: string | CommitTreeItem)
8282 }
8383} ;
8484
85+ const commandDiffCommitFile = async ( commitItem : CommitTreeItem ) => {
86+ const commitSha = commitItem . commit . sha ;
87+ if ( ! commitSha ) {
88+ return ;
89+ }
90+ const { repo } = await router . getState ( ) ;
91+ const activeDocumentUri = vscode . window . activeTextEditor ?. document ?. uri ;
92+ const fileUri = activeDocumentUri ?. with ( {
93+ authority : `${ repo } +${ commitSha } ` ,
94+ query : '' ,
95+ } ) ;
96+ return vscode . commands . executeCommand ( 'github1s.commands.openFilePreviousRevision' , fileUri ) ;
97+ } ;
98+
8599// this command is used in `source control commit list view`
86100const commandOpenCommitOnOfficialPage = async ( commitItemOrSha ?: string | CommitTreeItem ) => {
87101 const commitSha = commitItemOrSha
@@ -127,6 +141,7 @@ export const registerCommitCommands = (context: vscode.ExtensionContext) => {
127141 vscode . commands . registerCommand ( 'github1s.commands.refreshCommitList' , commandRefreshCommitList ) ,
128142 vscode . commands . registerCommand ( 'github1s.commands.searchCommit' , commandSwitchToCommit ) ,
129143 vscode . commands . registerCommand ( 'github1s.commands.switchToCommit' , commandSwitchToCommit ) ,
144+ vscode . commands . registerCommand ( 'github1s.commands.diffCommitFile' , commandDiffCommitFile ) ,
130145 vscode . commands . registerCommand ( 'github1s.commands.openCommitOnGitHub' , commandOpenCommitOnOfficialPage ) ,
131146 vscode . commands . registerCommand ( 'github1s.commands.openCommitOnGitLab' , commandOpenCommitOnOfficialPage ) ,
132147 vscode . commands . registerCommand ( 'github1s.commands.openCommitOnBitbucket' , commandOpenCommitOnOfficialPage ) ,
0 commit comments