Reduce usage of EditorAction.enabled
This commit is contained in:
parent
85e4ab959f
commit
6027655101
|
@ -46,22 +46,7 @@ abstract class ExecCommandAction extends EditorAction {
|
|||
}
|
||||
}
|
||||
|
||||
abstract class ClipboardWritingAction extends ExecCommandAction {
|
||||
|
||||
public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
if (!super.enabled(accessor, editor)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (browser.enableEmptySelectionClipboard) {
|
||||
return true;
|
||||
} else {
|
||||
return !editor.getSelection().isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ExecCommandCutAction extends ClipboardWritingAction {
|
||||
class ExecCommandCutAction extends ExecCommandAction {
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
|
@ -87,9 +72,17 @@ class ExecCommandCutAction extends ClipboardWritingAction {
|
|||
order: 1
|
||||
};
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
|
||||
if (!browser.enableEmptySelectionClipboard && editor.getSelection().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.run(accessor, editor);
|
||||
}
|
||||
}
|
||||
|
||||
class ExecCommandCopyAction extends ClipboardWritingAction {
|
||||
class ExecCommandCopyAction extends ExecCommandAction {
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
|
@ -115,6 +108,14 @@ class ExecCommandCopyAction extends ClipboardWritingAction {
|
|||
order: 2
|
||||
};
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
|
||||
if (!browser.enableEmptySelectionClipboard && editor.getSelection().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.run(accessor, editor);
|
||||
}
|
||||
}
|
||||
|
||||
class ExecCommandPasteAction extends ExecCommandAction {
|
||||
|
|
|
@ -328,15 +328,6 @@ class OpenLinkAction extends EditorAction {
|
|||
this._precondition = null;
|
||||
}
|
||||
|
||||
public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean {
|
||||
let linkDetector = LinkDetector.get(editor);
|
||||
if (linkDetector.isComputing()) {
|
||||
// optimistic enablement while state is being computed
|
||||
return true;
|
||||
}
|
||||
return !!linkDetector.getLinkOccurence(editor.getPosition());
|
||||
}
|
||||
|
||||
public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void {
|
||||
let linkDetector = LinkDetector.get(editor);
|
||||
let link = linkDetector.getLinkOccurence(editor.getPosition());
|
||||
|
|
Loading…
Reference in a new issue