mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -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:
@@ -3,30 +3,23 @@ import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||
import BlameAnnotationController from '../blameAnnotationController';
|
||||
import { EditorCommand } from './commands';
|
||||
import { Commands } from '../constants';
|
||||
import GitProvider from '../gitProvider';
|
||||
import { Logger } from '../logger';
|
||||
|
||||
export default class ToggleBlameCommand extends EditorCommand {
|
||||
constructor(private git: GitProvider, private annotationController: BlameAnnotationController) {
|
||||
constructor(private annotationController: BlameAnnotationController) {
|
||||
super(Commands.ToggleBlame);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string) {
|
||||
if (sha) {
|
||||
return this.annotationController.toggleBlameAnnotation(editor, sha);
|
||||
}
|
||||
|
||||
if (!(uri instanceof Uri)) {
|
||||
if (!editor.document) return undefined;
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string): Promise<any> {
|
||||
try {
|
||||
const blame = await this.git.getBlameForLine(uri.fsPath, editor.selection.active.line);
|
||||
return this.annotationController.toggleBlameAnnotation(editor, blame && blame.commit.sha);
|
||||
if (sha) {
|
||||
return this.annotationController.toggleBlameAnnotation(editor, sha);
|
||||
}
|
||||
|
||||
return this.annotationController.toggleBlameAnnotation(editor, editor.selection.active.line);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ToggleBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex);
|
||||
Logger.error('GitLens.ToggleBlameCommand', ex);
|
||||
return window.showErrorMessage(`Unable to show blame annotations. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user