Browse Source

Fixes Open Files|Revisions|All Changes * commands

main
Eric Amodio 5 years ago
parent
commit
88850d85b4
2 changed files with 53 additions and 58 deletions
  1. +6
    -6
      package.json
  2. +47
    -52
      src/views/viewCommands.ts

+ 6
- 6
package.json View File

@ -2741,12 +2741,12 @@
"category": "GitLens"
},
{
"command": "gitlens.views.openChangedFileChanges",
"command": "gitlens.views.openChangedFileDiffs",
"title": "Open All Changes",
"category": "GitLens"
},
{
"command": "gitlens.views.openChangedFileChangesWithWorking",
"command": "gitlens.views.openChangedFileDiffsWithWorking",
"title": "Open All Changes with Working Tree",
"category": "GitLens"
},
@ -3686,11 +3686,11 @@
"when": "false"
},
{
"command": "gitlens.views.openChangedFileChanges",
"command": "gitlens.views.openChangedFileDiffs",
"when": "false"
},
{
"command": "gitlens.views.openChangedFileChangesWithWorking",
"command": "gitlens.views.openChangedFileDiffsWithWorking",
"when": "false"
},
{
@ -4705,12 +4705,12 @@
"group": "1_gitlens_1@1"
},
{
"command": "gitlens.views.openChangedFileChanges",
"command": "gitlens.views.openChangedFileDiffs",
"when": "viewItem =~ /gitlens:(commit|stash|results:files)\\b/",
"group": "2_gitlens@1"
},
{
"command": "gitlens.views.openChangedFileChangesWithWorking",
"command": "gitlens.views.openChangedFileDiffsWithWorking",
"when": "viewItem =~ /gitlens:(commit|stash|results:files)\\b/",
"group": "2_gitlens@2"
},

+ 47
- 52
src/views/viewCommands.ts View File

@ -3,7 +3,6 @@ import { commands, env, TextDocumentShowOptions, Uri, window } from 'vscode';
import {
Commands,
DiffWithCommandArgs,
DiffWithCommandArgsRevision,
DiffWithPreviousCommandArgs,
DiffWithWorkingCommandArgs,
GitCommandsCommandArgs,
@ -115,10 +114,10 @@ export class ViewCommands {
commands.registerCommand('gitlens.views.openFileRevision', this.openFileRevision, this);
commands.registerCommand('gitlens.views.openFileRevisionInRemote', this.openFileRevisionInRemote, this);
commands.registerCommand('gitlens.views.openChangedFiles', this.openChangedFiles, this);
commands.registerCommand('gitlens.views.openChangedFileChanges', this.openChangedFileChanges, this);
commands.registerCommand('gitlens.views.openChangedFileDiffs', this.openChangedFileDiffs, this);
commands.registerCommand(
'gitlens.views.openChangedFileChangesWithWorking',
this.openChangedFileChangesWithWorking,
'gitlens.views.openChangedFileDiffsWithWorking',
this.openChangedFileDiffsWithWorking,
this
);
commands.registerCommand('gitlens.views.openChangedFileRevisions', this.openChangedFileRevisions, this);
@ -697,18 +696,16 @@ export class ViewCommands {
}
@debug()
private async openChangedFileChanges(
node: CommitNode | StashNode | ResultsFilesNode,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
) {
private async openChangedFiles(node: CommitNode | StashNode | ResultsFilesNode, options?: TextDocumentShowOptions) {
if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
return;
}
options = { preserveFocus: false, preview: false, ...options };
let repoPath: string;
let files;
let ref1: string;
let ref2: string;
let ref: string;
if (node instanceof ResultsFilesNode) {
const { diff } = await node.getFilesQueryResults();
@ -716,13 +713,11 @@ export class ViewCommands {
repoPath = node.repoPath;
files = diff;
ref1 = node.ref1;
ref2 = node.ref2;
ref = node.ref1 || node.ref2;
} else {
repoPath = node.commit.repoPath;
files = node.commit.files;
ref1 = node.commit.previousSha !== undefined ? node.commit.previousSha : GitService.deletedOrMissingSha;
ref2 = node.commit.sha;
ref = node.commit.sha;
}
if (files.length > 20) {
@ -735,27 +730,31 @@ export class ViewCommands {
}
for (const file of files) {
if (file.status === 'A') continue;
const uri1 = GitUri.fromFile(file, repoPath);
const uri2 = file.status === 'R' ? GitUri.fromFile(file, repoPath, ref2, true) : uri1;
const uri = GitUri.fromFile(file, repoPath, ref);
await this.openDiffWith(repoPath, { uri: uri1, sha: ref1 }, { uri: uri2, sha: ref2 }, options);
const args: OpenWorkingFileCommandArgs = {
uri: uri,
showOptions: options
};
await commands.executeCommand(Commands.OpenWorkingFile, undefined, args);
}
}
@debug()
private async openChangedFileChangesWithWorking(
private async openChangedFileDiffs(
node: CommitNode | StashNode | ResultsFilesNode,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
options?: TextDocumentShowOptions
) {
if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
return;
}
options = { preserveFocus: false, preview: false, ...options };
let repoPath: string;
let files;
let ref: string;
let ref1: string;
let ref2: string;
if (node instanceof ResultsFilesNode) {
const { diff } = await node.getFilesQueryResults();
@ -763,11 +762,13 @@ export class ViewCommands {
repoPath = node.repoPath;
files = diff;
ref = node.ref1 || node.ref2;
ref1 = node.ref1;
ref2 = node.ref2;
} else {
repoPath = node.commit.repoPath;
files = node.commit.files;
ref = node.commit.sha;
ref1 = node.commit.previousSha !== undefined ? node.commit.previousSha : GitService.deletedOrMissingSha;
ref2 = node.commit.sha;
}
if (files.length > 20) {
@ -779,27 +780,34 @@ export class ViewCommands {
if (result === undefined || result.title === 'No') return;
}
let diffArgs: DiffWithCommandArgs;
for (const file of files) {
if (file.status === 'A' || file.status === 'D') continue;
if (file.status === 'A') continue;
const args: DiffWithWorkingCommandArgs = {
const uri1 = GitUri.fromFile(file, repoPath);
const uri2 = file.status === 'R' ? GitUri.fromFile(file, repoPath, ref2, true) : uri1;
diffArgs = {
repoPath: repoPath,
lhs: { uri: uri1, sha: ref1 },
rhs: { uri: uri2, sha: ref2 },
showOptions: options
};
const uri = GitUri.fromFile(file, repoPath, ref);
await commands.executeCommand(Commands.DiffWithWorking, uri, args);
void (await commands.executeCommand(Commands.DiffWith, diffArgs));
}
}
@debug()
private async openChangedFiles(
private async openChangedFileDiffsWithWorking(
node: CommitNode | StashNode | ResultsFilesNode,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
options?: TextDocumentShowOptions
) {
if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
return;
}
options = { preserveFocus: false, preview: false, ...options };
let repoPath: string;
let files;
let ref: string;
@ -827,25 +835,28 @@ export class ViewCommands {
}
for (const file of files) {
const uri = GitUri.fromFile(file, repoPath, ref);
if (file.status === 'A' || file.status === 'D') continue;
const args: OpenWorkingFileCommandArgs = {
uri: uri,
const args: DiffWithWorkingCommandArgs = {
showOptions: options
};
await commands.executeCommand(Commands.OpenWorkingFile, undefined, args);
const uri = GitUri.fromFile(file, repoPath, ref);
await commands.executeCommand(Commands.DiffWithWorking, uri, args);
}
}
@debug()
private async openChangedFileRevisions(
node: CommitNode | StashNode | ResultsFilesNode,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
options?: TextDocumentShowOptions
) {
if (!(node instanceof CommitNode) && !(node instanceof StashNode) && !(node instanceof ResultsFilesNode)) {
return;
}
options = { preserveFocus: false, preview: false, ...options };
let repoPath: string;
let files;
let ref1: string;
@ -882,22 +893,6 @@ export class ViewCommands {
}
}
@debug()
private openDiffWith(
repoPath: string,
lhs: DiffWithCommandArgsRevision,
rhs: DiffWithCommandArgsRevision,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
) {
const diffArgs: DiffWithCommandArgs = {
repoPath: repoPath,
lhs: lhs,
rhs: rhs,
showOptions: options
};
return commands.executeCommand(Commands.DiffWith, diffArgs);
}
async terminalCreateBranch(node: ViewRefNode) {
if (!(node instanceof ViewRefNode)) return;

Loading…
Cancel
Save