提交 1730517d 编写于 作者: M Matt Bierner

Flatted out abstract class with only one impl

上级 98fb7aa3
......@@ -235,8 +235,36 @@ interface IDeleteLinesOperation {
positionColumn: number;
}
abstract class AbstractRemoveLinesAction extends EditorAction {
_getLinesToRemove(editor: ICodeEditor): IDeleteLinesOperation[] {
class DeleteLinesAction extends EditorAction {
constructor() {
super({
id: 'editor.action.deleteLines',
label: nls.localize('lines.delete', "Delete Line"),
alias: 'Delete Line',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K
}
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
let ops = this._getLinesToRemove(editor);
// Finally, construct the delete lines commands
let commands: ICommand[] = ops.map((op) => {
return new DeleteLinesCommand(op.startLineNumber, op.endLineNumber, op.positionColumn);
});
editor.pushUndoStop();
editor.executeCommands(this.id, commands);
editor.pushUndoStop();
}
private _getLinesToRemove(editor: ICodeEditor): IDeleteLinesOperation[] {
// Construct delete operations
let operations: IDeleteLinesOperation[] = editor.getSelections().map((s) => {
......@@ -277,36 +305,6 @@ abstract class AbstractRemoveLinesAction extends EditorAction {
}
}
class DeleteLinesAction extends AbstractRemoveLinesAction {
constructor() {
super({
id: 'editor.action.deleteLines',
label: nls.localize('lines.delete', "Delete Line"),
alias: 'Delete Line',
precondition: EditorContextKeys.writable,
kbOpts: {
kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_K
}
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
let ops = this._getLinesToRemove(editor);
// Finally, construct the delete lines commands
let commands: ICommand[] = ops.map((op) => {
return new DeleteLinesCommand(op.startLineNumber, op.endLineNumber, op.positionColumn);
});
editor.pushUndoStop();
editor.executeCommands(this.id, commands);
editor.pushUndoStop();
}
}
export class IndentLinesAction extends EditorAction {
constructor() {
super({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册