mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-18 09:45:36 -05:00
Fixes repo quickpick choices fail w/ no editors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
'use strict';
|
||||
import { commands, Disposable, TextEditor, TextEditorEdit } from 'vscode';
|
||||
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
|
||||
import { Commands } from '../constants';
|
||||
|
||||
export abstract class Command extends Disposable {
|
||||
@@ -31,4 +31,23 @@ export abstract class EditorCommand extends Disposable {
|
||||
}
|
||||
|
||||
abstract execute(editor: TextEditor, edit: TextEditorEdit, ...args: any[]): any;
|
||||
}
|
||||
|
||||
export abstract class ActiveEditorCommand extends Disposable {
|
||||
private _disposable: Disposable;
|
||||
|
||||
constructor(command: Commands) {
|
||||
super(() => this.dispose());
|
||||
this._disposable = commands.registerCommand(command, this._execute, this);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._disposable && this._disposable.dispose();
|
||||
}
|
||||
|
||||
_execute(...args: any[]): any {
|
||||
return this.execute(window.activeTextEditor, ...args);
|
||||
}
|
||||
|
||||
abstract execute(editor: TextEditor, ...args: any[]): any;
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
'use strict';
|
||||
import { Iterables } from '../system';
|
||||
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||
import { EditorCommand } from './commands';
|
||||
import { 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, FileQuickPickItem } from './quickPickItems';
|
||||
import { CommitQuickPick, CommitFilesQuickPick } from './quickPicks';
|
||||
|
||||
export default class ShowQuickCommitDetailsCommand extends EditorCommand {
|
||||
export default class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitProvider) {
|
||||
super(Commands.ShowQuickCommitDetails);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, sha?: string, commit?: GitCommit, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = { showFileHistory: true }) {
|
||||
async execute(editor: TextEditor, uri?: Uri, sha?: string, commit?: GitCommit, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = { showFileHistory: true }) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
if (!editor.document) return undefined;
|
||||
if (!editor || !editor.document) return undefined;
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,10 @@ export default class ShowQuickCommitDetailsCommand extends EditorCommand {
|
||||
|
||||
let repoPath = gitUri.repoPath;
|
||||
|
||||
let line = editor.selection.active.line;
|
||||
if (!sha) {
|
||||
const blameline = line - gitUri.offset;
|
||||
if (!editor) return undefined;
|
||||
|
||||
const blameline = editor.selection.active.line - gitUri.offset;
|
||||
if (blameline < 0) return undefined;
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
'use strict';
|
||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||
import { EditorCommand } from './commands';
|
||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||
import { ActiveEditorCommand } from './commands';
|
||||
import { Commands } from '../constants';
|
||||
import GitProvider, { GitUri } from '../gitProvider';
|
||||
import { Logger } from '../logger';
|
||||
import { CommandQuickPickItem } from './quickPickItems';
|
||||
import { FileCommitsQuickPick } from './quickPicks';
|
||||
|
||||
export default class ShowQuickFileHistoryCommand extends EditorCommand {
|
||||
export default class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
||||
|
||||
constructor(private git: GitProvider) {
|
||||
super(Commands.ShowQuickFileHistory);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, edit: TextEditorEdit, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem) {
|
||||
async execute(editor: TextEditor, uri?: Uri, maxCount?: number, goBackCommand?: CommandQuickPickItem) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
if (!editor.document) return undefined;
|
||||
if (!editor || !editor.document) return undefined;
|
||||
uri = editor.document.uri;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user