mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
Git - reveal specific file in the multi-file diff editor (#262458)
Git - reveal specific file in the multi-file diff ediotr
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<void> {
|
||||
async viewCommit(repository: Repository, historyItemId: string, revealUri?: Uri): Promise<void> {
|
||||
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')
|
||||
|
||||
@@ -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')}")`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user