mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 17:25:54 -05:00
Adds output channel logging, controlled by the `gitlens.advanced.output.level` setting Removes all debug logging, unless the `gitlens.advanced.output.debug` settings it on
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
'use strict';
|
|
import { TextEditor, TextEditorEdit, Uri } 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) {
|
|
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;
|
|
}
|
|
|
|
try {
|
|
const blame = await this.git.getBlameForLine(uri.fsPath, editor.selection.active.line);
|
|
this.annotationController.toggleBlameAnnotation(editor, blame && blame.commit.sha);
|
|
}
|
|
catch (ex) {
|
|
Logger.error('[GitLens.ToggleBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex);
|
|
}
|
|
}
|
|
} |