Skip to content

Commit

Permalink
Register quick diff provider
Browse files Browse the repository at this point in the history
Fixes #392
  • Loading branch information
alexr00 committed Jan 18, 2023
1 parent 697a3cf commit 70dd0de
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"contribCommentThreadAdditionalMenu",
"codiconDecoration",
"diffCommand",
"contribCommentEditorActionsMenu"
"contribCommentEditorActionsMenu",
"quickDiffProvider"
],
"version": "0.56.0",
"publisher": "GitHub",
Expand Down
13 changes: 13 additions & 0 deletions src/@types/vscode.proposed.quickdiffProvider.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {

// https://github.com/microsoft/vscode/issues/169012

export namespace window {
export function registerQuickDiffProvider(quickDiffProvider: QuickDiffProvider, label: string, rootUri?: Uri): Thenable<Disposable>;
}
}
12 changes: 12 additions & 0 deletions src/view/reviewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class ReviewManager {

this.updateState(true);
this.pollForStatusChange();
this.registerQuickDiff();
}

private registerListeners(): void {
Expand Down Expand Up @@ -170,6 +171,17 @@ export class ReviewManager {
GitHubCreatePullRequestLinkProvider.registerProvider(this._disposables, this, this._folderRepoManager);
}

private registerQuickDiff() {
vscode.window.registerQuickDiffProvider({
provideOriginalResource: (uri: vscode.Uri) => {
const changeNode = this.reviewModel.localFileChanges.find(changeNode => changeNode.changeModel.filePath.toString() === uri.toString());
if (changeNode) {
return changeNode.changeModel.parentFilePath;
}
}
}, 'GitHub Pull Request', this.repository.rootUri);
}

get statusBarItem() {
if (!this._statusBarItem) {
this._statusBarItem = vscode.window.createStatusBarItem('github.pullrequest.status', vscode.StatusBarAlignment.Left);
Expand Down

0 comments on commit 70dd0de

Please sign in to comment.