From 30a91ad63bd0bf927624e9e7b7801ca2c67c4114 Mon Sep 17 00:00:00 2001 From: Malachi Willey Date: Fri, 12 Oct 2018 18:39:38 -0500 Subject: [PATCH 1/2] Display a message before opening file diffs in the browser --- src/commands.ts | 6 ++++++ src/view/treeNodes/fileChangeNode.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/commands.ts b/src/commands.ts index baa88e5d6f..be9f7c476d 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -151,6 +151,12 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: Pu vscode.commands.executeCommand('vscode.diff', parentFilePath, filePath, fileName, opts); })); + context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffGitHub', (uri: string) => { + vscode.window + .showWarningMessage('This file is either too large, of an unsupported type, or has only been renamed. Would you like to view it on GitHub?', 'Open in GitHub') + .then(() => vscode.commands.executeCommand('vscode.open', uri)); + })); + context.subscriptions.push(vscode.commands.registerCommand('pr.deleteLocalBranch', async (e: PRNode) => { const pullRequestModel = ensurePR(prManager, e); const DELETE_BRANCH_FORCE = 'delete branch (even if not merged)'; diff --git a/src/view/treeNodes/fileChangeNode.ts b/src/view/treeNodes/fileChangeNode.ts index 54d8912c1a..6db62005e5 100644 --- a/src/view/treeNodes/fileChangeNode.ts +++ b/src/view/treeNodes/fileChangeNode.ts @@ -38,7 +38,7 @@ export class RemoteFileChangeNode extends TreeNode implements vscode.TreeItem { this.command = { title: 'show remote file', - command: 'vscode.open', + command: 'pr.openDiffGitHub', arguments: [ vscode.Uri.parse(this.blobUrl) ] From c72f2dc314d8ada924a441eccb5e375b4b11ae8d Mon Sep 17 00:00:00 2001 From: RMacfarlane Date: Thu, 23 May 2019 16:27:18 -0700 Subject: [PATCH 2/2] Only open in GitHub if button was pressed --- src/commands.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commands.ts b/src/commands.ts index be9f7c476d..6924e8def0 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -154,7 +154,11 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: Pu context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffGitHub', (uri: string) => { vscode.window .showWarningMessage('This file is either too large, of an unsupported type, or has only been renamed. Would you like to view it on GitHub?', 'Open in GitHub') - .then(() => vscode.commands.executeCommand('vscode.open', uri)); + .then(result => { + if (result === 'Open in GitHub') { + vscode.commands.executeCommand('vscode.open', uri); + } + }); })); context.subscriptions.push(vscode.commands.registerCommand('pr.deleteLocalBranch', async (e: PRNode) => {