diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index ccc68cf65a2..7c335f990ed 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -3550,14 +3550,16 @@ export class CommandCenter { return; } - const args: [Uri, Uri | undefined, Uri | undefined][] = []; + const title = `Git Stash #${stash.index}: ${stash.description}`; + const multiDiffSourceUri = toGitUri(Uri.file(repository.root), `stash@{${stash.index}}`, { scheme: 'git-stash' }); + const resources: { originalUri: Uri; modifiedUri: Uri }[] = []; for (const file of stashFiles) { const fileUri = Uri.file(path.join(repository.root, file)); - args.push([fileUri, fileUri, toGitUri(fileUri, `stash@{${stash.index}}`)]); + resources.push({ originalUri: fileUri, modifiedUri: toGitUri(fileUri, `stash@{${stash.index}}`) }); } - commands.executeCommand('vscode.changes', `Git Stash #${stash.index}: ${stash.description}`, args); + commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources }); } private async pickStash(repository: Repository, placeHolder: string): Promise { @@ -3649,16 +3651,19 @@ export class CommandCenter { const commit = await repository.getCommit(item.ref); const commitFiles = await repository.getCommitFiles(item.ref); - const args: [Uri, Uri | undefined, Uri | undefined][] = []; + const title = `${item.shortRef} - ${commit.message}`; + const multiDiffSourceUri = toGitUri(Uri.file(repository.root), item.ref, { scheme: 'git-commit' }); + + const resources: { originalUri: Uri; modifiedUri: Uri }[] = []; for (const commitFile of commitFiles) { const commitFileUri = Uri.file(path.join(repository.root, commitFile)); - args.push([commitFileUri, toGitUri(commitFileUri, item.previousRef), toGitUri(commitFileUri, item.ref)]); + resources.push({ originalUri: toGitUri(commitFileUri, item.previousRef), modifiedUri: toGitUri(commitFileUri, item.ref) }); } return { - command: 'vscode.changes', + command: '_workbench.openMultiDiffEditor', title: l10n.t('Open Commit'), - arguments: [`${item.shortRef} - ${commit.message}`, args, options] + arguments: [{ multiDiffSourceUri, title, resources }, options] }; } @@ -3827,9 +3832,9 @@ export class CommandCenter { const historyProvider = repository.historyProvider; const historyItemParentId = historyItem.parentIds.length > 0 ? historyItem.parentIds[0] : undefined; - const historyItemChanges = await historyProvider.provideHistoryItemChanges(historyItem.id, historyItemParentId); + const commitFiles = await historyProvider.provideHistoryItemChanges(historyItem.id, historyItemParentId); - if (historyItemChanges.length === 0) { + if (commitFiles.length === 0) { return; } @@ -3837,9 +3842,10 @@ export class CommandCenter { const originalShortRef = historyItem.parentIds.length > 0 ? historyItem.parentIds[0].substring(0, 8) : `${modifiedShortRef}^`; const title = l10n.t('Changes ({0} ↔ {1})', originalShortRef, modifiedShortRef); - const args = historyItemChanges.map(change => [change.uri, change.originalUri, change.modifiedUri]); + const multiDiffSourceUri = toGitUri(Uri.file(repository.root), historyItem.id, { scheme: 'git-commit' }); + const resources = commitFiles.map(change => ({ originalUri: change.originalUri, modifiedUri: change.modifiedUri })); - commands.executeCommand('vscode.changes', title, args); + commands.executeCommand('_workbench.openMultiDiffEditor', { multiDiffSourceUri, title, resources }); } private createCommand(id: string, key: string, method: Function, options: ScmCommandOptions): (...args: any[]) => any { diff --git a/extensions/git/src/uri.ts b/extensions/git/src/uri.ts index 5694c920d6b..3a39bfeaa64 100644 --- a/extensions/git/src/uri.ts +++ b/extensions/git/src/uri.ts @@ -20,6 +20,7 @@ export function fromGitUri(uri: Uri): GitUriParams { } export interface GitUriOptions { + scheme?: string; replaceFileExtension?: boolean; submoduleOf?: string; } @@ -45,11 +46,7 @@ export function toGitUri(uri: Uri, ref: string, options: GitUriOptions = {}): Ur path = `${path}.diff`; } - return uri.with({ - scheme: 'git', - path, - query: JSON.stringify(params) - }); + return uri.with({ scheme: options.scheme ?? 'git', path, query: JSON.stringify(params) }); } /**