Skip to content

Commit

Permalink
Reverts diff editor changes for diff w/ working
Browse files Browse the repository at this point in the history
Since we are going forward in time, the changes didn't make sense
  • Loading branch information
eamodio committed May 5, 2019
1 parent 00d3ee0 commit 25d3895
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 0 additions & 2 deletions src/commands/diffWithNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface DiffWithNextCommandArgs {
commit?: GitLogCommit;
range?: Range;

inDiffEditor?: boolean;
line?: number;
showOptions?: TextDocumentShowOptions;
}
Expand All @@ -36,7 +35,6 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.editor.document.uri, args);
}
}
args.inDiffEditor = true;
}

return this.execute(context.editor, context.uri, args);
Expand Down
25 changes: 4 additions & 21 deletions src/commands/diffWithWorking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { UriComparer } from '../comparers';
export interface DiffWithWorkingCommandArgs {
commit?: GitCommit;

inDiffEditor?: boolean;
line?: number;
showOptions?: TextDocumentShowOptions;
}
Expand All @@ -24,8 +23,8 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {

protected preExecute(context: CommandContext, args: DiffWithWorkingCommandArgs = {}) {
if (
context.command === Commands.DiffWithWorkingInDiff ||
(context.editor !== undefined && context.editor.viewColumn === undefined)
context.command === Commands.DiffWithWorkingInDiff
// || (context.editor !== undefined && context.editor.viewColumn === undefined)
) {
// HACK: If in a diff, try to determine if we are on the right or left side
// If there is a context uri and it doesn't match the editor uri, assume we are on the left
Expand All @@ -35,8 +34,6 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
return this.execute(context.editor, context.editor.document.uri, args);
}
}

args.inDiffEditor = true;
}

return this.execute(context.editor, context.uri, args);
Expand Down Expand Up @@ -66,18 +63,10 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {

const status = await Container.git.getStatusForFile(gitUri.repoPath!, gitUri.fsPath);
if (status !== undefined && status.indexStatus !== undefined) {
let sha = GitService.uncommittedStagedSha;
if (args.inDiffEditor) {
const commit = await Container.git.getCommitForFile(gitUri.repoPath!, gitUri.fsPath);
if (commit === undefined) return Messages.showCommitHasNoPreviousCommitWarningMessage();

sha = commit.sha;
}

const diffArgs: DiffWithCommandArgs = {
repoPath: gitUri.repoPath,
lhs: {
sha: sha,
sha: GitService.uncommittedStagedSha,
uri: gitUri.documentUri()
},
rhs: {
Expand All @@ -92,15 +81,9 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
}
}

// If we are in a diff editor, assume we are on the right side, and need to move back 2 revisions
let sha = gitUri.sha;
if (args.inDiffEditor && sha !== undefined) {
sha = `${sha}^`;
}

try {
args.commit = await Container.git.getCommitForFile(gitUri.repoPath, gitUri.fsPath, {
ref: sha,
ref: gitUri.sha,
firstIfNotFound: true
});
if (args.commit === undefined) {
Expand Down

0 comments on commit 25d3895

Please sign in to comment.