mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-14 01:25:43 -05:00
Fixes issue with executing blame command
And minor other positioning issues
This commit is contained in:
@@ -42,7 +42,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
|
||||
if (!lenses.find(l => l.range.start.line === 0 && l.range.end.line === 0)) {
|
||||
const docRange = document.validateRange(new Range(0, 1000000, 1000000, 1000000));
|
||||
lenses.push(new GitBlameCodeLens(this.blameProvider, document.fileName, docRange, new Range(0, 0, 0, docRange.start.character)));
|
||||
lenses.push(new GitHistoryCodeLens(this.blameProvider.repoPath, document.fileName, docRange.with(new Position(docRange.start.line, docRange.start.character + 1))));
|
||||
lenses.push(new GitHistoryCodeLens(this.blameProvider.repoPath, document.fileName, new Range(0, 1, 0, docRange.start.character)));
|
||||
}
|
||||
return lenses;
|
||||
});
|
||||
@@ -94,7 +94,7 @@ export default class GitCodeLensProvider implements CodeLensProvider {
|
||||
|
||||
const recentCommit = Array.from(blame.commits.values()).sort((a, b) => b.date.getTime() - a.date.getTime())[0];
|
||||
lens.command = {
|
||||
title: `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`,
|
||||
title: `${recentCommit.author}, ${moment(recentCommit.date).fromNow()}`, // - lines(${lens.blameRange.start.line + 1}-${lens.blameRange.end.line + 1})`,
|
||||
command: Commands.ShowBlameHistory,
|
||||
arguments: [Uri.file(lens.fileName), lens.blameRange, lens.range.start]
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import {CodeLens, commands, DocumentSelector, ExtensionContext, languages, Range, Uri, window, workspace} from 'vscode';
|
||||
import {CodeLens, commands, DocumentSelector, ExtensionContext, languages, Position, Range, Uri, window, workspace} from 'vscode';
|
||||
import GitCodeLensProvider, {GitBlameCodeLens} from './codeLensProvider';
|
||||
import GitContentProvider from './contentProvider';
|
||||
import {gitRepoPath} from './git';
|
||||
@@ -24,20 +24,22 @@ export function activate(context: ExtensionContext) {
|
||||
|
||||
context.subscriptions.push(workspace.registerTextDocumentContentProvider(GitContentProvider.scheme, new GitContentProvider(context, blameProvider)));
|
||||
|
||||
context.subscriptions.push(commands.registerCommand(Commands.ShowBlameHistory, (uri: Uri, blameRange?: Range, range?: Range) => {
|
||||
context.subscriptions.push(commands.registerCommand(Commands.ShowBlameHistory, (uri?: Uri, range?: Range, position?: Position) => {
|
||||
// If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
|
||||
if (!uri) {
|
||||
const doc = window.activeTextEditor && window.activeTextEditor.document;
|
||||
if (doc) {
|
||||
uri = doc.uri;
|
||||
blameRange = doc.validateRange(new Range(0, 0, 1000000, 1000000));
|
||||
range = doc.validateRange(new Range(0, 0, 0, 1000000));
|
||||
range = doc.validateRange(new Range(0, 0, 1000000, 1000000));
|
||||
position = doc.validateRange(new Range(0, 0, 0, 1000000)).start;
|
||||
}
|
||||
|
||||
if (!uri) return;
|
||||
}
|
||||
|
||||
return blameProvider.getBlameLocations(uri.path, blameProvider.repoPath, blameRange).then(locations => {
|
||||
return commands.executeCommand(VsCodeCommands.ShowReferences, uri, range, locations);
|
||||
console.log(uri.path, blameProvider.repoPath, range, position);
|
||||
return blameProvider.getBlameLocations(uri.path, blameProvider.repoPath, range).then(locations => {
|
||||
return commands.executeCommand(VsCodeCommands.ShowReferences, uri, position, locations);
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user