diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 0383518..bac9364 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -15,8 +15,11 @@ export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand { async execute(editor: TextEditor, uri?: Uri, maxCount?: number, commit?: GitCommit, goBackCommand?: CommandQuickPickItem) { if (!(uri instanceof Uri)) { - if (!editor || !editor.document) return undefined; - uri = editor.document.uri; + uri = editor && editor.document && editor.document.uri; + } + + if (!uri) { + return commands.executeCommand(Commands.ShowQuickRepoHistory); } const gitUri = GitUri.fromUri(uri, this.git); diff --git a/src/commands/showQuickRepoHistory.ts b/src/commands/showQuickRepoHistory.ts index c34a9c5..adfd49d 100644 --- a/src/commands/showQuickRepoHistory.ts +++ b/src/commands/showQuickRepoHistory.ts @@ -1,24 +1,21 @@ 'use strict'; -import { commands, Uri, window } from 'vscode'; -import { Command } from './commands'; +import { commands, TextEditor, Uri, window } from 'vscode'; +import { ActiveEditorCommand } from './commands'; import { Commands } from '../constants'; import GitProvider, { GitCommit, GitUri } from '../gitProvider'; import { Logger } from '../logger'; import { CommandQuickPickItem } from './quickPickItems'; import { RepoCommitsQuickPick } from './quickPicks'; -export default class ShowQuickRepoHistoryCommand extends Command { +export default class ShowQuickRepoHistoryCommand extends ActiveEditorCommand { constructor(private git: GitProvider, public repoPath: string) { super(Commands.ShowQuickRepoHistory); } - async execute(uri?: Uri, maxCount?: number, commit?: GitCommit, goBackCommand?: CommandQuickPickItem) { + async execute(editor: TextEditor, uri?: Uri, maxCount?: number, commit?: GitCommit, goBackCommand?: CommandQuickPickItem) { if (!(uri instanceof Uri)) { - const document = window.activeTextEditor && window.activeTextEditor.document; - if (document) { - uri = document.uri; - } + uri = editor && editor.document && editor.document.uri; } if (maxCount == null) {