Browse Source

Fixes issue with CodeLens on version files

main
Eric Amodio 7 years ago
parent
commit
6bff9a8f7b
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      src/gitRevisionCodeLensProvider.ts

+ 5
- 4
src/gitRevisionCodeLensProvider.ts View File

@ -26,11 +26,12 @@ export default class GitRevisionCodeLensProvider implements CodeLensProvider {
constructor(context: ExtensionContext, private git: GitProvider) { } constructor(context: ExtensionContext, private git: GitProvider) { }
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> { async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
const gitUri = GitUri.fromUri(document.uri, this.git);
const data = GitProvider.fromGitContentUri(document.uri);
const gitUri = new GitUri(Uri.file(data.fileName), data);
const lenses: CodeLens[] = []; const lenses: CodeLens[] = [];
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath);
const log = await this.git.getLogForFile(gitUri.fsPath, gitUri.sha, gitUri.repoPath, undefined, 2);
if (!log) return lenses; if (!log) return lenses;
const commit = (gitUri.sha && log.commits.get(gitUri.sha)) || Iterables.first(log.commits.values()); const commit = (gitUri.sha && log.commits.get(gitUri.sha)) || Iterables.first(log.commits.values());
@ -53,7 +54,7 @@ export default class GitRevisionCodeLensProvider implements CodeLensProvider {
_resolveDiffWithWorkingTreeCodeLens(lens: GitDiffWithWorkingCodeLens, token: CancellationToken): Thenable<CodeLens> { _resolveDiffWithWorkingTreeCodeLens(lens: GitDiffWithWorkingCodeLens, token: CancellationToken): Thenable<CodeLens> {
lens.command = { lens.command = {
title: `Compare (${lens.commit.sha}) with Working Tree`,
title: `Compare ${lens.commit.sha} with Working Tree`,
command: Commands.DiffWithWorking, command: Commands.DiffWithWorking,
arguments: [ arguments: [
Uri.file(lens.fileName), Uri.file(lens.fileName),
@ -66,7 +67,7 @@ export default class GitRevisionCodeLensProvider implements CodeLensProvider {
_resolveGitDiffWithPreviousCodeLens(lens: GitDiffWithPreviousCodeLens, token: CancellationToken): Thenable<CodeLens> { _resolveGitDiffWithPreviousCodeLens(lens: GitDiffWithPreviousCodeLens, token: CancellationToken): Thenable<CodeLens> {
lens.command = { lens.command = {
title: `Compare (${lens.commit.sha}) with Previous (${lens.commit.previousSha})`,
title: `Compare ${lens.commit.sha} with Previous ${lens.commit.previousSha}`,
command: Commands.DiffWithPrevious, command: Commands.DiffWithPrevious,
arguments: [ arguments: [
Uri.file(lens.fileName), Uri.file(lens.fileName),

Loading…
Cancel
Save