Skip to content

Commit 9964ea6

Browse files
author
Eric Amodio
committed
Fixes issue with executing blame command
And minor other positioning issues
1 parent 92beca2 commit 9964ea6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/codeLensProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
4242
if (!lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0)) {
4343
const docRange = document.validateRange(new Range(0, 1000000, 1000000, 1000000));
4444
lenses.push(new GitBlameCodeLens(this.blameProvider, document.fileName, docRange, new Range(0, 0, 0, docRange.start.character)));
45-
lenses.push(new GitHistoryCodeLens(this.blameProvider.repoPath, document.fileName, docRange.with(new Position(docRange.start.line, docRange.start.character + 1))));
45+
lenses.push(new GitHistoryCodeLens(this.blameProvider.repoPath, document.fileName, new Range(0, 1, 0, docRange.start.character)));
4646
}
4747
return lenses;
4848
});
@@ -94,7 +94,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
9494

9595
const recentCommit = Array.from(blame.commits.values()).sort((a, b) => b.date.getTime() - a.date.getTime())[0];
9696
lens.command = {
97-
title: `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`,
97+
title: `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`, // - lines(${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1})`,
9898
command: Commands.ShowBlameHistory,
9999
arguments: [Uri.file(lens.fileName), lens.blameRange, lens.range.start]
100100
};

src/extension.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
import {CodeLens, commands, DocumentSelector, ExtensionContext, languages, Range, Uri, window, workspace} from 'vscode';
2+
import {CodeLens, commands, DocumentSelector, ExtensionContext, languages, Position, Range, Uri, window, workspace} from 'vscode';
33
import GitCodeLensProvider, {GitBlameCodeLens} from './codeLensProvider';
44
import GitContentProvider from './contentProvider';
55
import {gitRepoPath} from './git';
@@ -24,20 +24,22 @@ export function activate(context: ExtensionContext) {
2424

2525
context.subscriptions.push(workspace.registerTextDocumentContentProvider(GitContentProvider.scheme, new GitContentProvider(context, blameProvider)));
2626

27-
context.subscriptions.push(commands.registerCommand(Commands.ShowBlameHistory, (uri: Uri, blameRange?: Range, range?: Range) => {
27+
context.subscriptions.push(commands.registerCommand(Commands.ShowBlameHistory, (uri?: Uri, range?: Range, position?: Position) => {
28+
// If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
2829
if (!uri) {
2930
const doc = window.activeTextEditor && window.activeTextEditor.document;
3031
if (doc) {
3132
uri = doc.uri;
32-
blameRange = doc.validateRange(new Range(0, 0, 1000000, 1000000));
33-
range = doc.validateRange(new Range(0, 0, 0, 1000000));
33+
range = doc.validateRange(new Range(0, 0, 1000000, 1000000));
34+
position = doc.validateRange(new Range(0, 0, 0, 1000000)).start;
3435
}
3536

3637
if (!uri) return;
3738
}
3839

39-
return blameProvider.getBlameLocations(uri.path, blameProvider.repoPath, blameRange).then(locations => {
40-
return commands.executeCommand(VsCodeCommands.ShowReferences, uri, range, locations);
40+
console.log(uri.path, blameProvider.repoPath, range, position);
41+
return blameProvider.getBlameLocations(uri.path, blameProvider.repoPath, range).then(locations => {
42+
return commands.executeCommand(VsCodeCommands.ShowReferences, uri, position, locations);
4143
});
4244
}));
4345

0 commit comments

Comments
 (0)