Fixes another off-by-one issue when diffing with caching

Refactored commands and blame annotations
This commit is contained in:
Eric Amodio
2016-09-26 00:55:54 -04:00
parent 23b2c679a9
commit d2d72f0d54
16 changed files with 519 additions and 455 deletions

View File

@@ -0,0 +1,26 @@
'use strict'
import {commands, Position, Range, TextEditor, TextEditorEdit, Uri} from 'vscode';
import {EditorCommand} from './commands';
import {BuiltInCommands, Commands} from '../constants';
import GitProvider from '../gitProvider';
export default class ShowBlameHistoryCommand extends EditorCommand {
constructor(private git: GitProvider) {
super(Commands.ShowBlameHistory);
}
execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, range?: Range, position?: Position) {
if (!(uri instanceof Uri)) {
if (!editor.document) return;
uri = editor.document.uri;
// If the command is executed manually -- treat it as a click on the root lens (i.e. show blame for the whole file)
range = editor.document.validateRange(new Range(0, 0, 1000000, 1000000));
position = editor.document.validateRange(new Range(0, 0, 0, 1000000)).start;
}
return this.git.getBlameLocations(uri.fsPath, range)
.catch(ex => console.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex))
.then(locations => commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations));
}
}