mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-29 01:25:42 -05:00
Adds shortcut for gitlens.showQuickRepoHistory Adds gitlens.advanced.maxQuickHistory to limit the number of quick history entries to show Adds gitlens.diffLineWithPrevious as alt context menu item for gitlens.diffWithPrevious Adds gitlens.diffLineWithWorking as alt context menu item for gitlens.diffWithWorking Adds gitlens.showFileHistory as alt context menu item for gitlens.showQuickFileHistory Removes context menu for gitlens.diffLineWithPrevious Removes context menu for gitlens.diffLineWithWorking Replaces gitlens.menus.fileDiff.enabled & gitlens.menus.lineDiff.enabled with gitlens.menus.diff.enabled
38 lines
1.7 KiB
TypeScript
38 lines
1.7 KiB
TypeScript
'use strict';
|
|
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
|
import { EditorCommand } from './commands';
|
|
import { BuiltInCommands, Commands } from '../constants';
|
|
import GitProvider, { GitUri } from '../gitProvider';
|
|
import { Logger } from '../logger';
|
|
|
|
export default class ShowBlameHistoryCommand extends EditorCommand {
|
|
constructor(private git: GitProvider) {
|
|
super(Commands.ShowBlameHistory);
|
|
}
|
|
|
|
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, range?: Range, position?: Position, sha?: string, line?: number) {
|
|
if (!(uri instanceof Uri)) {
|
|
if (!editor.document) return undefined;
|
|
uri = editor.document.uri;
|
|
}
|
|
|
|
if (range == null || position == null) {
|
|
// 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;
|
|
}
|
|
|
|
const gitUri = GitUri.fromUri(uri, this.git);
|
|
|
|
try {
|
|
const locations = await this.git.getBlameLocations(gitUri.fsPath, range, gitUri.sha, gitUri.repoPath, sha, line);
|
|
if (!locations) return window.showWarningMessage(`Unable to show blame history. File is probably not under source control`);
|
|
|
|
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations);
|
|
}
|
|
catch (ex) {
|
|
Logger.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex);
|
|
return window.showErrorMessage(`Unable to show blame history. See output channel for more details`);
|
|
}
|
|
}
|
|
} |