From 9179b70875a982fb83467d8fa8a625f7e52a8809 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Tue, 27 Jun 2017 01:18:15 -0400 Subject: [PATCH] Avoids re-setting the line if it is already set --- src/commands/diffWithBranch.ts | 4 +++- src/commands/diffWithNext.ts | 4 +++- src/commands/diffWithWorking.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands/diffWithBranch.ts b/src/commands/diffWithBranch.ts index 9d7dd78..b7d86b3 100644 --- a/src/commands/diffWithBranch.ts +++ b/src/commands/diffWithBranch.ts @@ -25,7 +25,9 @@ export class DiffWithBranchCommand extends ActiveEditorCommand { uri = getCommandUri(uri, editor); if (uri === undefined) return undefined; - args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); + if (args.line === undefined) { + args.line = editor === undefined ? 0 : editor.selection.active.line; + } const gitUri = await GitUri.fromUri(uri, this.git); if (!gitUri.repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open branch compare`); diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index f54d7fd..7b3b09a 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -25,7 +25,9 @@ export class DiffWithNextCommand extends ActiveEditorCommand { uri = getCommandUri(uri, editor); if (uri === undefined) return undefined; - args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); + if (args.line === undefined) { + args.line = editor === undefined ? 0 : editor.selection.active.line; + } if (args.commit === undefined || !(args.commit instanceof GitLogCommit) || args.range !== undefined) { const gitUri = await GitUri.fromUri(uri, this.git); diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index db219e5..ef6373f 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -23,7 +23,9 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { uri = getCommandUri(uri, editor); if (uri === undefined) return undefined; - args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); + if (args.line === undefined) { + args.line = editor === undefined ? 0 : editor.selection.active.line; + } if (args.commit === undefined || GitService.isUncommitted(args.commit.sha)) { const gitUri = await GitUri.fromUri(uri, this.git);