mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-21 17:26:05 -05:00
Renamed to GitLens
Reworked Uri scheme to drastically reduce encoded data (big perf improvement)
This commit is contained in:
@@ -1,30 +1,47 @@
|
||||
'use strict';
|
||||
import {commands, DocumentSelector, ExtensionContext, languages, workspace} from 'vscode';
|
||||
import GitCodeLensProvider from './codeLensProvider';
|
||||
import {CodeLens, commands, DocumentSelector, ExtensionContext, languages, Uri, window, workspace} from 'vscode';
|
||||
import GitCodeLensProvider, {GitBlameCodeLens} from './codeLensProvider';
|
||||
import GitContentProvider from './contentProvider';
|
||||
import {gitRepoPath} from './git';
|
||||
import {Commands, VsCodeCommands} from './constants';
|
||||
import GitBlameProvider from './gitBlameProvider';
|
||||
import {Commands, VsCodeCommands, WorkspaceState} from './constants';
|
||||
|
||||
// this method is called when your extension is activated
|
||||
export function activate(context: ExtensionContext) {
|
||||
// Workspace not using a folder. No access to git repo.
|
||||
if (!workspace.rootPath) {
|
||||
console.warn('Git CodeLens inactive: no rootPath');
|
||||
console.warn('GitLens inactive: no rootPath');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Git CodeLens active: ${workspace.rootPath}`);
|
||||
|
||||
console.log(`GitLens active: ${workspace.rootPath}`);
|
||||
gitRepoPath(workspace.rootPath).then(repoPath => {
|
||||
context.subscriptions.push(workspace.registerTextDocumentContentProvider(GitContentProvider.scheme, new GitContentProvider(context)));
|
||||
context.workspaceState.update(WorkspaceState.RepoPath, repoPath);
|
||||
|
||||
const blameProvider = new GitBlameProvider();
|
||||
context.subscriptions.push(blameProvider);
|
||||
|
||||
context.subscriptions.push(workspace.registerTextDocumentContentProvider(GitContentProvider.scheme, new GitContentProvider(context, blameProvider)));
|
||||
|
||||
context.subscriptions.push(commands.registerCommand(Commands.ShowBlameHistory, (...args) => {
|
||||
return commands.executeCommand(VsCodeCommands.ShowReferences, ...args);
|
||||
if (args && args.length) {
|
||||
return commands.executeCommand(VsCodeCommands.ShowReferences, ...args);
|
||||
}
|
||||
|
||||
// const uri = window.activeTextEditor && window.activeTextEditor.document && window.activeTextEditor.document.uri;
|
||||
// if (uri) {
|
||||
// return (commands.executeCommand(VsCodeCommands.ExecuteCodeLensProvider, uri) as Promise<CodeLens[]>).then(lenses => {
|
||||
// const lens = <GitBlameCodeLens>lenses.find(l => l instanceof GitBlameCodeLens);
|
||||
// if (lens) {
|
||||
// return commands.executeCommand(Commands.ShowBlameHistory, Uri.file(lens.fileName), lens.range.start, lens.locations);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}));
|
||||
|
||||
const selector: DocumentSelector = { scheme: 'file' };
|
||||
context.subscriptions.push(languages.registerCodeLensProvider(selector, new GitCodeLensProvider(repoPath)));
|
||||
context.subscriptions.push(languages.registerCodeLensProvider(selector, new GitCodeLensProvider(context, blameProvider)));
|
||||
}).catch(reason => console.warn(reason));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user