mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-14 03:58:31 -05:00
Fixes another off-by-one issue when diffing with caching
Refactored commands and blame annotations
This commit is contained in:
26
src/commands/showBlameHistory.ts
Normal file
26
src/commands/showBlameHistory.ts
Normal 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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user