diff --git a/extensions/git/src/blame.ts b/extensions/git/src/blame.ts index eb65a8ea0ab..379f70fd3a5 100644 --- a/extensions/git/src/blame.ts +++ b/extensions/git/src/blame.ts @@ -299,7 +299,7 @@ export class GitBlameController { } // Commands - markdownString.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(documentUri, hash)} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([documentUri, hash]))} "${l10n.t('Open Commit')}")`); + markdownString.appendMarkdown(`[\`$(git-commit) ${getCommitShortHash(documentUri, hash)} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([documentUri, hash, documentUri]))} "${l10n.t('Open Commit')}")`); markdownString.appendMarkdown(' '); markdownString.appendMarkdown(`[$(copy)](command:git.copyContentToClipboard?${encodeURIComponent(JSON.stringify(hash))} "${l10n.t('Copy Commit Hash')}")`); @@ -765,10 +765,13 @@ class GitBlameStatusBarItem { blameInformation[0].blameInformation as BlameInformation, cancellationToken); }; + const uri = window.activeTextEditor.document.uri; + const hash = blameInformation[0].blameInformation.hash; + this._statusBarItem.command = { title: l10n.t('Open Commit'), command: 'git.viewCommit', - arguments: [window.activeTextEditor.document.uri, blameInformation[0].blameInformation.hash] + arguments: [uri, hash, uri] } satisfies Command; } diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 480d440be01..c18679403f8 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -4779,11 +4779,12 @@ export class CommandCenter { const title = `${item.shortRef} - ${truncate(commit.message)}`; const multiDiffSourceUri = Uri.from({ scheme: 'scm-history-item', path: `${repository.root}/${commitParentId}..${commit.hash}` }); + const reveal = { modifiedUri: toGitUri(uri, commit.hash) }; return { command: '_workbench.openMultiDiffEditor', title: l10n.t('Open Commit'), - arguments: [{ multiDiffSourceUri, title, resources }, options] + arguments: [{ multiDiffSourceUri, title, resources, reveal }, options] }; } @@ -5032,7 +5033,7 @@ export class CommandCenter { } @command('git.viewCommit', { repository: true }) - async viewCommit(repository: Repository, historyItemId: string): Promise { + async viewCommit(repository: Repository, historyItemId: string, revealUri?: Uri): Promise { if (!repository || !historyItemId) { return; } @@ -5049,8 +5050,9 @@ export class CommandCenter { const changes = await repository.diffTrees(historyItemParentId, historyItemId); const resources = changes.map(c => toMultiFileDiffEditorUris(c, historyItemParentId, historyItemId)); + const reveal = revealUri ? { modifiedUri: toGitUri(revealUri, historyItemId) } : undefined; - await commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources }); + await commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources, reveal }); } @command('git.copyContentToClipboard') diff --git a/extensions/git/src/timelineProvider.ts b/extensions/git/src/timelineProvider.ts index 54d1c0661d1..0e90abd0082 100644 --- a/extensions/git/src/timelineProvider.ts +++ b/extensions/git/src/timelineProvider.ts @@ -94,7 +94,7 @@ export class GitTimelineItem extends TimelineItem { if (hash && shortHash) { this.tooltip.appendMarkdown(`---\n\n`); - this.tooltip.appendMarkdown(`[\`$(git-commit) ${shortHash} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([uri, hash]))} "${l10n.t('Open Commit')}")`); + this.tooltip.appendMarkdown(`[\`$(git-commit) ${shortHash} \`](command:git.viewCommit?${encodeURIComponent(JSON.stringify([uri, hash, uri]))} "${l10n.t('Open Commit')}")`); this.tooltip.appendMarkdown(' '); this.tooltip.appendMarkdown(`[$(copy)](command:git.copyContentToClipboard?${encodeURIComponent(JSON.stringify(hash))} "${l10n.t('Copy Commit Hash')}")`);