mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Moves Commands into commands file
This commit is contained in:
71
src/commands.ts
Normal file
71
src/commands.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
'use strict';
|
||||||
|
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
|
||||||
|
|
||||||
|
export type Commands = 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
||||||
|
export const Commands = {
|
||||||
|
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
||||||
|
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
|
||||||
|
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
||||||
|
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
|
||||||
|
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
|
||||||
|
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
|
||||||
|
ShowBlame: 'gitlens.showBlame' as Commands,
|
||||||
|
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
||||||
|
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
|
||||||
|
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
|
||||||
|
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
|
||||||
|
ShowQuickRepoHistory: 'gitlens.showQuickRepoHistory' as Commands,
|
||||||
|
ShowQuickRepoStatus: 'gitlens.showQuickRepoStatus' as Commands,
|
||||||
|
ToggleBlame: 'gitlens.toggleBlame' as Commands,
|
||||||
|
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
|
||||||
|
};
|
||||||
|
|
||||||
|
export abstract class Command 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract execute(...args: any[]): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class EditorCommand extends Disposable {
|
||||||
|
private _disposable: Disposable;
|
||||||
|
|
||||||
|
constructor(command: Commands) {
|
||||||
|
super(() => this.dispose());
|
||||||
|
this._disposable = commands.registerTextEditorCommand(command, this.execute, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
this._disposable && this._disposable.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
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,53 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
import { commands, Disposable, TextEditor, TextEditorEdit, window } from 'vscode';
|
|
||||||
import { Commands } from '../constants';
|
|
||||||
|
|
||||||
export abstract class Command 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract execute(...args: any[]): any;
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class EditorCommand extends Disposable {
|
|
||||||
private _disposable: Disposable;
|
|
||||||
|
|
||||||
constructor(command: Commands) {
|
|
||||||
super(() => this.dispose());
|
|
||||||
this._disposable = commands.registerTextEditorCommand(command, this.execute, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
dispose() {
|
|
||||||
this._disposable && this._disposable.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
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,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitUri } from '../gitProvider';
|
import GitProvider, { GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { copy } from 'copy-paste';
|
import { copy } from 'copy-paste';
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitUri } from '../gitProvider';
|
import GitProvider, { GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { copy } from 'copy-paste';
|
import { copy } from 'copy-paste';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { BuiltInCommands, Commands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { BuiltInCommands, Commands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { BuiltInCommands, Commands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import BlameAnnotationController from '../blameAnnotationController';
|
import BlameAnnotationController from '../blameAnnotationController';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export default class ShowBlameCommand extends EditorCommand {
|
export default class ShowBlameCommand extends EditorCommand {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { BuiltInCommands, Commands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitUri } from '../gitProvider';
|
import GitProvider, { GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { BuiltInCommands, Commands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import GitProvider, { GitUri } from '../gitProvider';
|
import GitProvider, { GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, FileQuickPickItem } from './quickPickItems';
|
import { CommandQuickPickItem, FileQuickPickItem } from './quickPickItems';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem } from './quickPickItems';
|
import { CommandQuickPickItem } from './quickPickItems';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand } from './commands';
|
import { ActiveEditorCommand, Commands } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
import GitProvider, { GitCommit, GitUri } from '../gitProvider';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem } from './quickPickItems';
|
import { CommandQuickPickItem } from './quickPickItems';
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
||||||
import BlameAnnotationController from '../blameAnnotationController';
|
import BlameAnnotationController from '../blameAnnotationController';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export default class ToggleBlameCommand extends EditorCommand {
|
export default class ToggleBlameCommand extends EditorCommand {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { TextEditor, TextEditorEdit } from 'vscode';
|
import { TextEditor, TextEditorEdit } from 'vscode';
|
||||||
import { EditorCommand } from './commands';
|
import { Commands, EditorCommand } from '../commands';
|
||||||
import { Commands } from '../constants';
|
|
||||||
import GitProvider from '../gitProvider';
|
import GitProvider from '../gitProvider';
|
||||||
|
|
||||||
export default class ToggleCodeLensCommand extends EditorCommand {
|
export default class ToggleCodeLensCommand extends EditorCommand {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Commands } from './constants';
|
import { Commands } from './commands';
|
||||||
|
|
||||||
export type BlameAnnotationStyle = 'compact' | 'expanded' | 'trailing';
|
export type BlameAnnotationStyle = 'compact' | 'expanded' | 'trailing';
|
||||||
export const BlameAnnotationStyle = {
|
export const BlameAnnotationStyle = {
|
||||||
|
|||||||
@@ -16,24 +16,6 @@ export const BuiltInCommands = {
|
|||||||
ToggleRenderWhitespace: 'editor.action.toggleRenderWhitespace' as BuiltInCommands
|
ToggleRenderWhitespace: 'editor.action.toggleRenderWhitespace' as BuiltInCommands
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Commands = 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
|
||||||
export const Commands = {
|
|
||||||
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
|
||||||
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
|
|
||||||
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
|
||||||
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
|
|
||||||
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,
|
|
||||||
DiffLineWithWorking: 'gitlens.diffLineWithWorking' as Commands,
|
|
||||||
ShowBlame: 'gitlens.showBlame' as Commands,
|
|
||||||
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
|
||||||
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
|
|
||||||
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
|
|
||||||
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
|
|
||||||
ShowQuickRepoHistory: 'gitlens.showQuickRepoHistory' as Commands,
|
|
||||||
ToggleBlame: 'gitlens.toggleBlame' as Commands,
|
|
||||||
ToggleCodeLens: 'gitlens.toggleCodeLens' as Commands
|
|
||||||
};
|
|
||||||
|
|
||||||
export type DocumentSchemes = 'file' | 'gitlens-git';
|
export type DocumentSchemes = 'file' | 'gitlens-git';
|
||||||
export const DocumentSchemes = {
|
export const DocumentSchemes = {
|
||||||
File: 'file' as DocumentSchemes,
|
File: 'file' as DocumentSchemes,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Functions, Iterables, Strings } from './system';
|
import { Functions, Iterables, Strings } from './system';
|
||||||
import { CancellationToken, CodeLens, CodeLensProvider, commands, DocumentSelector, Event, EventEmitter, ExtensionContext, Position, Range, SymbolInformation, SymbolKind, TextDocument, Uri, workspace } from 'vscode';
|
import { CancellationToken, CodeLens, CodeLensProvider, commands, DocumentSelector, Event, EventEmitter, ExtensionContext, Position, Range, SymbolInformation, SymbolKind, TextDocument, Uri, workspace } from 'vscode';
|
||||||
import { BuiltInCommands, Commands, DocumentSchemes } from './constants';
|
import { Commands } from './commands';
|
||||||
|
import { BuiltInCommands, DocumentSchemes } from './constants';
|
||||||
import { CodeLensCommand, CodeLensLocation, IConfig, ICodeLensLanguageLocation } from './configuration';
|
import { CodeLensCommand, CodeLensLocation, IConfig, ICodeLensLanguageLocation } from './configuration';
|
||||||
import GitProvider, { GitCommit, GitUri, IGitBlame, IGitBlameLines } from './gitProvider';
|
import GitProvider, { GitCommit, GitUri, IGitBlame, IGitBlameLines } from './gitProvider';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Iterables } from './system';
|
import { Iterables } from './system';
|
||||||
import { CancellationToken, CodeLens, CodeLensProvider, DocumentSelector, ExtensionContext, Range, TextDocument, Uri } from 'vscode';
|
import { CancellationToken, CodeLens, CodeLensProvider, DocumentSelector, ExtensionContext, Range, TextDocument, Uri } from 'vscode';
|
||||||
import { Commands, DocumentSchemes } from './constants';
|
import { Commands } from './commands';
|
||||||
|
import { DocumentSchemes } from './constants';
|
||||||
import GitProvider, { GitCommit, GitUri } from './gitProvider';
|
import GitProvider, { GitCommit, GitUri } from './gitProvider';
|
||||||
|
|
||||||
export class GitDiffWithWorkingCodeLens extends CodeLens {
|
export class GitDiffWithWorkingCodeLens extends CodeLens {
|
||||||
|
|||||||
Reference in New Issue
Block a user