mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-24 01:35:37 -05:00
Adds support for git commands on scheme=git
Rewrites blame annotation controller and provider - fixes whitespace issues, reduces overhead, and provides better performance Rewrites status bar blame support - reduces overhead and provides better performance Adds showFileHistory command to status bar Renames showHistory to showFileHistory Fixes log to use iso 8601 for dates
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
'use strict';
|
||||
import { ExtensionContext, TextDocumentContentProvider, Uri } from 'vscode';
|
||||
import { ExtensionContext, TextDocumentContentProvider, Uri, window } from 'vscode';
|
||||
import { DocumentSchemes } from './constants';
|
||||
import GitProvider from './gitProvider';
|
||||
import { Logger } from './logger';
|
||||
import * as path from 'path';
|
||||
|
||||
export default class GitContentProvider implements TextDocumentContentProvider {
|
||||
static scheme = DocumentSchemes.Git;
|
||||
|
||||
constructor(context: ExtensionContext, private git: GitProvider) { }
|
||||
|
||||
provideTextDocumentContent(uri: Uri): string | Thenable<string> {
|
||||
async provideTextDocumentContent(uri: Uri): Promise<string> {
|
||||
const data = GitProvider.fromGitUri(uri);
|
||||
return this.git.getVersionedFileText(data.originalFileName || data.fileName, data.repoPath, data.sha)
|
||||
.then(text => data.decoration ? `${data.decoration}\n${text}` : text)
|
||||
.catch(ex => Logger.error('[GitLens.GitContentProvider]', 'getVersionedFileText', ex));
|
||||
const fileName = data.originalFileName || data.fileName;
|
||||
try {
|
||||
let text = await this.git.getVersionedFileText(fileName, data.repoPath, data.sha);
|
||||
if (data.decoration) {
|
||||
text = `${data.decoration}\n${text}`;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.GitContentProvider]', 'getVersionedFileText', ex);
|
||||
await window.showErrorMessage(`Unable to show Git revision ${data.sha} of '${path.relative(data.repoPath, fileName)}'`);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user