Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@
{
"command": "pr.openDiffView",
"title": "Open Diff View",
"category": "GitHub Pull Requests",
"icon": {
"light": "resources/icons/light/open-change.svg",
"dark": "resources/icons/dark/open-change.svg"
}
},
{
"command": "pr.openChangedFile",
"title": "Open Changed File in PR",
"category": "GitHub Pull Requests"
},
{
Expand Down Expand Up @@ -240,6 +249,10 @@
"command": "review.openFile",
"when": "false"
},
{
"command": "pr.openChangedFile",
"when": "false"
},
{
"command": "pr.close",
"when": "config.git.enabled && github:inReviewMode"
Expand Down Expand Up @@ -338,7 +351,12 @@
{
"command": "review.openFile",
"group": "inline",
"when": "view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
"when": "config.git.openDiffOnClick && view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
},
{
"command": "pr.openDiffView",
"group": "inline",
"when": "!config.git.openDiffOnClick && view == prStatus && viewItem =~ /filechange(?!:DELETE)/"
}
],
"editor/title": [
Expand Down
2 changes: 1 addition & 1 deletion src/authentication/githubServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ResponseExpired extends Error {
get message() { return 'Token response expired'; }
}

const SEPARATOR = '/', SEPARATOR_LEN = SEPARATOR.length
const SEPARATOR = '/', SEPARATOR_LEN = SEPARATOR.length;

/**
* Hydrate and verify the signature of a message produced with `encode`
Expand Down
8 changes: 7 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ export function registerCommands(context: vscode.ExtensionContext, prManager: IP
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(e.blobUrl));
}));

context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (parentFilePath: string, filePath: string, fileName: string, isPartial: boolean, opts: any) => {
context.subscriptions.push(vscode.commands.registerCommand('pr.openDiffView', (gitFileChangeNode: GitFileChangeNode) => {
const parentFilePath = gitFileChangeNode.parentFilePath;
const filePath = gitFileChangeNode.filePath;
const fileName = gitFileChangeNode.fileName;
const isPartial = gitFileChangeNode.isPartial;
const opts = gitFileChangeNode.opts;

if (isPartial) {
vscode.window.showInformationMessage('Your local repository is not up to date so only partial content is being displayed');
}
Expand Down
8 changes: 8 additions & 0 deletions src/view/reviewManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ export class ReviewManager implements vscode.DecorationProvider {

vscode.commands.executeCommand('vscode.open', vscode.Uri.file(nodePath.resolve(this._repository.rootUri.fsPath, params.path)), opts);
}));
this._disposables.push(vscode.commands.registerCommand('pr.openChangedFile', (value: GitFileChangeNode) => {
const openDiff = vscode.workspace.getConfiguration().get('git.openDiffOnClick');
if (openDiff) {
return vscode.commands.executeCommand('pr.openDiffView', value);
} else {
return vscode.commands.executeCommand('review.openFile', value);
}
}));

this._disposables.push(_repository.state.onDidChange(e => {
const oldHead = this._previousRepositoryState.HEAD;
Expand Down
17 changes: 6 additions & 11 deletions src/view/treeNodes/fileChangeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class GitFileChangeNode extends TreeNode implements vscode.TreeItem {
public parentSha: string;
public contextValue: string;
public command: vscode.Command;
public opts: vscode.TextDocumentShowOptions;

constructor(
public readonly pullRequest: IPullRequestModel,
Expand All @@ -153,7 +154,7 @@ export class GitFileChangeNode extends TreeNode implements vscode.TreeItem {
this.iconPath = vscode.ThemeIcon.File;
this.resourceUri = toFileChangeNodeUri(this.filePath, comments.length > 0, status);

let opts: vscode.TextDocumentShowOptions = {
this.opts = {
preserveFocus: true
};

Expand All @@ -169,21 +170,15 @@ export class GitFileChangeNode extends TreeNode implements vscode.TreeItem {
if (diffLine) {
// If the diff is a deletion, the new line number is invalid so use the old line number. Ensure the line number is positive.
let lineNumber = Math.max(getZeroBased(diffLine.type === DiffChangeType.Delete ? diffLine.oldLineNumber : diffLine.newLineNumber), 0);
opts.selection = new vscode.Range(lineNumber, 0, lineNumber, 0);
this.opts.selection = new vscode.Range(lineNumber, 0, lineNumber, 0);
}
}
}

this.command = {
title: 'show diff',
command: 'pr.openDiffView',
arguments: [
this.parentFilePath,
this.filePath,
this.fileName,
this.isPartial,
opts
]
title: 'open changed file',
command: 'pr.openChangedFile',
arguments: [this]
};
}

Expand Down