|
1 | 1 | 'use strict'; |
2 | | -import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode'; |
| 2 | +import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode'; |
3 | 3 | import { ActiveEditorCommand, Commands, getCommandUri } from './common'; |
4 | 4 | import { BuiltInCommands, GlyphChars } from '../constants'; |
5 | 5 | import { GitCommit, GitService, GitUri } from '../gitService'; |
@@ -51,16 +51,18 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { |
51 | 51 | try { |
52 | 52 | const compare = await this.git.getVersionedFile(args.commit.repoPath, args.commit.uri.fsPath, args.commit.sha); |
53 | 53 |
|
| 54 | + if (args.line !== undefined && args.line !== 0) { |
| 55 | + if (args.showOptions === undefined) { |
| 56 | + args.showOptions = {}; |
| 57 | + } |
| 58 | + args.showOptions.selection = new Range(args.line, 0, args.line, 0); |
| 59 | + } |
| 60 | + |
54 | 61 | await commands.executeCommand(BuiltInCommands.Diff, |
55 | 62 | Uri.file(compare), |
56 | 63 | Uri.file(path.resolve(gitUri.repoPath, workingFileName)), |
57 | 64 | `${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(workingFileName)}`, |
58 | 65 | args.showOptions); |
59 | | - |
60 | | - if (args.line === undefined || args.line === 0) return undefined; |
61 | | - |
62 | | - // TODO: Figure out how to focus the left pane |
63 | | - return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: args.line, at: 'center' }); |
64 | 66 | } |
65 | 67 | catch (ex) { |
66 | 68 | Logger.error(ex, 'DiffWithWorkingCommand', 'getVersionedFile'); |
|
0 commit comments