From 66d4cf81f588f53e30a1f29b3f278c88466bd6dd Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 18 May 2020 02:29:57 -0400 Subject: [PATCH] Fixes issue w/ previous line diff line # being off --- src/commands/diffLineWithPrevious.ts | 2 +- src/git/gitService.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index 6670af4..60fdf2a 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -53,7 +53,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand { sha: diffUris.current.sha || '', uri: diffUris.current.documentUri(), }, - line: args.line, + line: diffUris.line, showOptions: args.showOptions, }; return commands.executeCommand(Commands.DiffWith, diffArgs); diff --git a/src/git/gitService.ts b/src/git/gitService.ts index 7ccd90c..5a7c818 100644 --- a/src/git/gitService.ts +++ b/src/git/gitService.ts @@ -2270,7 +2270,7 @@ export class GitService implements Disposable { editorLine: number, ref: string | undefined, skip: number = 0, - ): Promise<{ current: GitUri; previous: GitUri | undefined } | undefined> { + ): Promise<{ current: GitUri; previous: GitUri | undefined; line: number } | undefined> { if (ref === GitService.deletedOrMissingSha) return undefined; let fileName = GitUri.relativeTo(uri, repoPath); @@ -2302,6 +2302,7 @@ export class GitService implements Disposable { return { current: GitUri.fromFile(fileName, repoPath, undefined), previous: GitUri.fromFile(fileName, repoPath, GitService.uncommittedStagedSha), + line: editorLine, }; } } @@ -2310,6 +2311,7 @@ export class GitService implements Disposable { return { current: GitUri.fromFile(fileName, repoPath, undefined), previous: await this.getPreviousUri(repoPath, uri, undefined, skip, editorLine), + line: editorLine, }; } @@ -2353,6 +2355,7 @@ export class GitService implements Disposable { return { current: current, previous: await this.getPreviousUri(repoPath, uri, undefined, skip, editorLine), + line: editorLine, }; } @@ -2379,7 +2382,8 @@ export class GitService implements Disposable { return { current: current, - previous: previous || (await this.getPreviousUri(repoPath, uri, ref, skip, editorLine)), + previous: previous ?? (await this.getPreviousUri(repoPath, uri, ref, skip, editorLine)), + line: editorLine, }; }