This commit is contained in:
Eric Amodio
2016-11-03 03:09:33 -04:00
parent 8df6b80725
commit 409be335f9
38 changed files with 1094 additions and 520 deletions

View File

@@ -1,8 +1,8 @@
'use strict'
import {TextEditor, TextEditorEdit, Uri} from 'vscode';
'use strict';
import { TextEditor, TextEditorEdit, Uri } from 'vscode';
import BlameAnnotationController from '../blameAnnotationController';
import {EditorCommand} from './commands';
import {Commands} from '../constants';
import { EditorCommand } from './commands';
import { Commands } from '../constants';
import GitProvider from '../gitProvider';
export default class ShowBlameCommand extends EditorCommand {
@@ -10,18 +10,22 @@ export default class ShowBlameCommand extends EditorCommand {
super(Commands.ShowBlame);
}
execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string) {
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;
if (!editor.document) return undefined;
uri = editor.document.uri;
}
return this.git.getBlameForLine(uri.fsPath, editor.selection.active.line)
.then(blame => this.annotationController.showBlameAnnotation(editor, blame && blame.commit.sha))
.catch(ex => console.error('[GitLens.ShowBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex));
try {
const blame = await this.git.getBlameForLine(uri.fsPath, editor.selection.active.line);
this.annotationController.showBlameAnnotation(editor, blame && blame.commit.sha);
}
catch (ex) {
console.error('[GitLens.ShowBlameCommand]', `getBlameForLine(${editor.selection.active.line})`, ex);
}
}
}