mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -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;
|
||||
}
|
||||
Reference in New Issue
Block a user