mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-28 01:25:48 -05:00
Fixes another off-by-one issue when diffing with caching
Refactored commands and blame annotations
This commit is contained in:
33
src/commands/commands.ts
Normal file
33
src/commands/commands.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
import {commands, Disposable, TextEditor, TextEditorEdit} from 'vscode';
|
||||
import {Commands} from '../constants';
|
||||
|
||||
export abstract class Command extends Disposable {
|
||||
private _subscriptions: Disposable;
|
||||
|
||||
constructor(command: Commands) {
|
||||
super(() => this.dispose());
|
||||
this._subscriptions = commands.registerCommand(command, this.execute, this);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._subscriptions && this._subscriptions.dispose();
|
||||
}
|
||||
|
||||
abstract execute(...args): any;
|
||||
}
|
||||
|
||||
export abstract class EditorCommand extends Disposable {
|
||||
private _subscriptions: Disposable;
|
||||
|
||||
constructor(command: Commands) {
|
||||
super(() => this.dispose());
|
||||
this._subscriptions = commands.registerTextEditorCommand(command, this.execute, this);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._subscriptions && this._subscriptions.dispose();
|
||||
}
|
||||
|
||||
abstract execute(editor: TextEditor, edit: TextEditorEdit, ...args): any;
|
||||
}
|
||||
Reference in New Issue
Block a user