From a306ba2b984a30662118e17441e5fb1e80bf7452 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 14 Jun 2017 02:01:24 -0400 Subject: [PATCH] Stops trying to set the line if we don't have one --- src/commands/diffLineWithPrevious.ts | 2 ++ src/commands/diffWithBranch.ts | 2 ++ src/commands/diffWithNext.ts | 2 ++ src/commands/diffWithPrevious.ts | 11 +++++++++-- src/commands/diffWithWorking.ts | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index 6d4106a..7c650a6 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -79,6 +79,8 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand { `${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)} (${gitUri.shortSha})`, args.showOptions); + if (args.line === undefined || args.line === 0) return undefined; + // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); } diff --git a/src/commands/diffWithBranch.ts b/src/commands/diffWithBranch.ts index 7c3ded4..9d7dd78 100644 --- a/src/commands/diffWithBranch.ts +++ b/src/commands/diffWithBranch.ts @@ -48,6 +48,8 @@ export class DiffWithBranchCommand extends ActiveEditorCommand { `${path.basename(gitUri.fsPath)} (${branch}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)}`, args.showOptions); + if (args.line === undefined || args.line === 0) return undefined; + // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); } diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index c7b6466..f85afc1 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -63,6 +63,8 @@ export class DiffWithNextCommand extends ActiveEditorCommand { `${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(args.commit.nextUri.fsPath)} (${args.commit.nextShortSha})`, args.showOptions); + if (args.line === undefined || args.line === 0) return undefined; + // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); } diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 9be9933..642c1b6 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -26,9 +26,14 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { uri = getCommandUri(uri, editor); if (uri === undefined) return undefined; - args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); + if (args.commit !== undefined && args.commit.type !== 'file') { + args.line = 0; + } + else { + args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line); + } - if (args.commit === undefined || (args.commit.type !== 'file') || args.range !== undefined) { + if (args.commit === undefined || args.commit.type !== 'file' || args.range !== undefined) { const gitUri = await GitUri.fromUri(uri, this.git); try { @@ -62,6 +67,8 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { `${path.basename(args.commit.previousUri.fsPath)} (${args.commit.previousShortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha})`, args.showOptions); + if (args.line === undefined || args.line === 0) return undefined; + // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); } diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index 6197261..db219e5 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -54,6 +54,8 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { `${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(workingFileName)}`, args.showOptions); + if (args.line === undefined || args.line === 0) return undefined; + // TODO: Figure out how to focus the left pane return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); }