diff --git a/src/vs/editor/browser/widget/diffEditorWidget.ts b/src/vs/editor/browser/widget/diffEditorWidget.ts index 466e02fa89b6ba0e101968e561a3b2313cc5e5e7..76972ea734d9f3053bbf151598eba4e55c7c6287 100644 --- a/src/vs/editor/browser/widget/diffEditorWidget.ts +++ b/src/vs/editor/browser/widget/diffEditorWidget.ts @@ -601,6 +601,10 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif return this.modifiedEditor.getActions(); } + public getSupportedActions(): IAction[] { + return this.modifiedEditor.getSupportedActions(); + } + public getAction(id:string): IAction { return this.modifiedEditor.getAction(id); } diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index 36a1c76910a3bfbcd4dba7151a4db20638bd51b7..b2e5dd849d2f6e7dfc40432d9b2f9146b623a028 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -24,7 +24,7 @@ import {EditorState} from 'vs/editor/common/core/editorState'; import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; import {Selection} from 'vs/editor/common/core/selection'; -import {DynamicEditorAction} from 'vs/editor/common/editorAction'; +import {EditorAction, DynamicEditorAction} from 'vs/editor/common/editorAction'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {CharacterHardWrappingLineMapperFactory} from 'vs/editor/common/viewModel/characterHardWrappingLineMapper'; @@ -576,6 +576,13 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom return result; } + public getSupportedActions(): IAction[] { + let result = this.getActions(); + result = result.filter(action => (action).isSupported()); + + return result; + } + public getAction(id:string): IAction { var contribution = this.contributions[id]; if (contribution) { diff --git a/src/vs/editor/common/editorActionEnablement.ts b/src/vs/editor/common/editorActionEnablement.ts index a5f52dec0cac49877ee9ffb59e21b6d42de6ce32..ef651a28cf76893f9def0ec53d1d5227077c8127 100644 --- a/src/vs/editor/common/editorActionEnablement.ts +++ b/src/vs/editor/common/editorActionEnablement.ts @@ -12,7 +12,6 @@ export enum Behaviour { WidgetFocus = 1 << 1, Writeable = 1 << 2, UpdateOnModelChange = 1 << 3, - UpdateOnConfigurationChange = 1 << 4, UpdateOnCursorPositionChange = 1 << 6 } diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 2afc763b15b8759d9e593f1810332ce296b025db..2ae3a0ef7b975af9731901b99fc18f6aae59d180 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -3588,6 +3588,11 @@ export interface IEditor { */ getActions(): IAction[]; + /** + * Returns all actions associated with this editor. + */ + getSupportedActions(): IAction[]; + /** * Saves current view state of the editor in a serializable object. */ diff --git a/src/vs/editor/contrib/quickOpen/browser/quickCommand.ts b/src/vs/editor/contrib/quickOpen/browser/quickCommand.ts index df06663e687aad73d43fdda503b1665e14574f6f..8dd74a6451a9a164f37c83e8eeda6e4708f7a0b8 100644 --- a/src/vs/editor/contrib/quickOpen/browser/quickCommand.ts +++ b/src/vs/editor/contrib/quickOpen/browser/quickCommand.ts @@ -12,7 +12,6 @@ import {TPromise} from 'vs/base/common/winjs.base'; import {IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel} from 'vs/base/parts/quickopen/browser/quickOpenModel'; import {IAutoFocus, Mode} from 'vs/base/parts/quickopen/common/quickOpen'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; -import {EditorAction} from 'vs/editor/common/editorAction'; import {ICommonCodeEditor, IEditor, IEditorActionDescriptorData} from 'vs/editor/common/editorCommon'; import {BaseEditorQuickOpenAction} from './editorQuickOpen'; @@ -80,7 +79,7 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction { } _getModel(value: string): QuickOpenModel { - return new QuickOpenModel(this._editorActionsToEntries(this.editor.getActions(), value)); + return new QuickOpenModel(this._editorActionsToEntries(this.editor.getSupportedActions(), value)); } _sort(elementA: QuickOpenEntryGroup, elementB: QuickOpenEntryGroup): number { @@ -96,13 +95,7 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction { for (let i = 0; i < actions.length; i++) { let action = actions[i]; - let editorAction = action; - - if (!editorAction.isSupported()) { - continue; // do not show actions that are not supported in this context - } - - let keys = this._keybindingService.lookupKeybindings(editorAction.id).map(k => this._keybindingService.getLabelFor(k)); + let keys = this._keybindingService.lookupKeybindings(action.id).map(k => this._keybindingService.getLabelFor(k)); if (action.label) { let highlights = matchesFuzzy(searchValue, action.label); diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 07a1b7915ef8efa553af08cb6fca12d78f3815a8..97952473502e59c9febda53ba3f45b01a03cfd4b 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2888,6 +2888,10 @@ declare module monaco.editor { * Returns all actions associated with this editor. */ getActions(): IAction[]; + /** + * Returns all actions associated with this editor. + */ + getSupportedActions(): IAction[]; /** * Saves current view state of the editor in a serializable object. */ diff --git a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts index ca00f951e8866227119e6c3df6ed47e8903952e0..a68ea1e4630ac56f713dcf5ef77c9a707c1aa2ec 100644 --- a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts @@ -256,8 +256,8 @@ export class CommandsHandler extends QuickOpenHandler { let activeEditorControl = (activeEditor ? activeEditor.getControl() : null); let editorActions: EditorAction[] = []; - if (activeEditorControl && types.isFunction(activeEditorControl.getActions)) { - editorActions = activeEditorControl.getActions(); + if (activeEditorControl && types.isFunction(activeEditorControl.getSupportedActions)) { + editorActions = activeEditorControl.getSupportedActions(); } let editorEntries = this.editorActionsToEntries(editorActions, searchValue); @@ -319,12 +319,7 @@ export class CommandsHandler extends QuickOpenHandler { for (let i = 0; i < actions.length; i++) { let action = actions[i]; - let editorAction = action; - if (!editorAction.isSupported()) { - continue; // do not show actions that are not supported in this context - } - - let keys = this.keybindingService.lookupKeybindings(editorAction.id); + let keys = this.keybindingService.lookupKeybindings(action.id); let keyLabel = keys.map(k => this.keybindingService.getLabelFor(k)); let keyAriaLabel = keys.map(k => this.keybindingService.getAriaLabelFor(k)); let label = action.label;