diff --git a/src/vs/editor/browser/view/viewImpl.ts b/src/vs/editor/browser/view/viewImpl.ts index b24e046701f068d71dc02f7658240226eaeef1fd..a028f59584633bc155b548512c45be139a7a53dd 100644 --- a/src/vs/editor/browser/view/viewImpl.ts +++ b/src/vs/editor/browser/view/viewImpl.ts @@ -89,7 +89,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp private accumulatedModelEvents: EmitterEvent[]; private _renderAnimationFrame: IDisposable; - private _keybindingService: IKeybindingService; private _editorTextFocusContextKey: IKeybindingContextKey; constructor( @@ -175,8 +174,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp private createTextArea(keybindingService: IKeybindingService): void { // Text Area (The focus will always be in the textarea when the cursor is blinking) this.textArea = document.createElement('textarea'); - this._keybindingService = keybindingService.createScoped(this.textArea); - this._editorTextFocusContextKey = EditorContextKeys.TextFocus.bindTo(this._keybindingService); + this._editorTextFocusContextKey = EditorContextKeys.TextFocus.bindTo(keybindingService); this.textArea.className = editorBrowser.ClassNames.TEXTAREA; this.textArea.setAttribute('wrap', 'off'); this.textArea.setAttribute('autocorrect', 'off'); @@ -508,7 +506,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp this.viewParts = []; this.layoutProvider.dispose(); - this._keybindingService.dispose(); + this._editorTextFocusContextKey.reset(); } // --- begin Code Editor APIs diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index f045c33abd4e5dfe500f1f6c7a359e9c487a3f70..de566a1d8c9c6c6fe2c27a8e6c9003c8c695ec0e 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -581,7 +581,8 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom public getSupportedActions(): editorCommon.IEditorAction[] { let result = this.getActions(); - result = result.filter(action => action.isSupported()); + + result = result.filter(action => action.isSupported(true)); return result; } diff --git a/src/vs/editor/common/editorAction.ts b/src/vs/editor/common/editorAction.ts index 60f4b39f66db48c7ba0c7457c3edeae12d89829c..3136c45ba536a3a4c36eb7287745afc24501e201 100644 --- a/src/vs/editor/common/editorAction.ts +++ b/src/vs/editor/common/editorAction.ts @@ -41,9 +41,9 @@ export class InternalEditorAction extends AbstractInternalEditorAction implement }); } - public isSupported():boolean { + public isSupported(forceEditorTextFocus:boolean):boolean { return this._instantiationService.invokeFunction((accessor) => { - return this._actual.supported(accessor, this._editor); + return this._actual.supported(accessor, this._editor, forceEditorTextFocus); }); } @@ -68,7 +68,7 @@ export class DynamicEditorAction extends AbstractInternalEditorAction implements return true; } - public isSupported():boolean { + public isSupported(forceEditorTextFocus:boolean):boolean { return true; } diff --git a/src/vs/editor/common/editorCommon.ts b/src/vs/editor/common/editorCommon.ts index 128d96e990271812db01f922c401728fcc55dd7c..a71b40ac1ee660d0d903cc90061e5eef50ce24c5 100644 --- a/src/vs/editor/common/editorCommon.ts +++ b/src/vs/editor/common/editorCommon.ts @@ -3025,12 +3025,12 @@ export namespace EditorContextKeys { * A context key that is set when the editor's text has focus (cursor is blinking). * @internal */ - export const TextFocus = new KbCtxKey('editorTextFocus', undefined); + export const TextFocus = new KbCtxKey('editorTextFocus', false); /** * A context key that is set when the editor's text or an editor's widget has focus. * @internal */ - export const Focus = new KbCtxKey('editorFocus', undefined); + export const Focus = new KbCtxKey('editorFocus', false); /** * A context key that is set when the editor's text is readonly. @@ -3482,7 +3482,7 @@ export interface IEditorAction { label: string; alias: string; enabled: boolean; - isSupported():boolean; + isSupported(forceEditorTextFocus:boolean):boolean; run(): TPromise; } diff --git a/src/vs/editor/common/editorCommonExtensions.ts b/src/vs/editor/common/editorCommonExtensions.ts index fafee7effe429f26a4a84d82d54518cf1e6a28f0..e5421919231cba2ba42e94704601cb43e730e215 100644 --- a/src/vs/editor/common/editorCommonExtensions.ts +++ b/src/vs/editor/common/editorCommonExtensions.ts @@ -8,7 +8,7 @@ import {illegalArgument} from 'vs/base/common/errors'; import URI from 'vs/base/common/uri'; import {TPromise} from 'vs/base/common/winjs.base'; import {ServicesAccessor, IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {KbExpr} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, IKeybindingService} from 'vs/platform/keybinding/common/keybinding'; import {CommandsRegistry} from 'vs/platform/commands/common/commands'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; import {Registry} from 'vs/platform/platform'; @@ -33,13 +33,46 @@ export interface IEditorCommandMenuOptions { // --- Editor Actions +// let recorded: EditorAction[] = []; +function record(desc:EditorAction) { + return; + // let stack = new Error().stack; + // desc.callsite = stack.split('\n')[3]; + // recorded.push(desc); +} +function analyze() { + return; + // recorded.sort((a, b) => a.id < b.id ? -1 : (a.id > b.id ? 1 : 0)); + // recorded.forEach((desc) => { + // let rightpad = (str:string, cnt:number) => { + // while (str.length < cnt) { + // str = str + ' '; + // } + // return str; + // }; + + // if (typeof desc._precondition === 'undefined') { + // console.warn('MISSING PRECONDITION FOR ' + desc.id + desc.callsite); + // } else { + // let prec = desc._precondition ? desc._precondition.serialize() : 'null'; + // if (desc._needsWritableEditor && prec.indexOf('!editorReadonly') === -1) { + // console.warn('BELOW COMMAND DOES NOT PRECONDITION CORRECTLY WRITABLE!'); + // } + // console.log(rightpad(desc.id, 50) + '' + desc._needsWritableEditor + '\t\t' + rightpad(prec, 50) + '\t\t' + desc.callsite); + // } + // }); + // recorded = []; +} + export module CommonEditorRegistry { export function registerEditorAction(desc:EditorAction) { + record(desc); (Registry.as(Extensions.EditorCommonContributions)).registerEditorAction(desc); } export function getEditorActions(): EditorAction[] { + analyze(); return (Registry.as(Extensions.EditorCommonContributions)).getEditorActions(); } @@ -152,6 +185,8 @@ export abstract class EditorAction extends ConfigEditorCommand { public alias: string; public menuOpts: IEditorCommandMenuOptions; + public _precondition: KbExpr; + constructor(id:string, label:string, alias:string, needsWritableEditor:boolean) { super(id); this.label = label; @@ -170,17 +205,26 @@ export abstract class EditorAction extends ConfigEditorCommand { } public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { + if (!this.supported(accessor, editor, false)) { + return false; + } if (this._needsWritableEditor) { return !editor.getConfiguration().readOnly; } return true; } - public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { - if (this._needsWritableEditor) { - return !editor.getConfiguration().readOnly; + public supported(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor, forceEditorTextFocus:boolean): boolean { + const kbService = accessor.get(IKeybindingService); + + let override = null; + if (forceEditorTextFocus) { + override = { + editorTextFocus: true + }; } - return true; + + return kbService.contextMatchesRules(this._precondition, override); } public abstract run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void | TPromise; diff --git a/src/vs/editor/contrib/clipboard/browser/clipboard.ts b/src/vs/editor/contrib/clipboard/browser/clipboard.ts index 64fed84fd5df55153353c17c64a0aeafc5b2bd6b..543bb944f6339a7004c73730f423e6f9967edf23 100644 --- a/src/vs/editor/contrib/clipboard/browser/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/browser/clipboard.ts @@ -61,20 +61,6 @@ abstract class ClipboardWritingAction extends ExecCommandAction { } } -function editorCursorIsInEditableRange(editor:editorCommon.ICommonCodeEditor): boolean { - let model = editor.getModel(); - if (!model) { - return false; - } - let hasEditableRange = model.hasEditableRange(); - if (!hasEditableRange) { - return true; - } - let editableRange = model.getEditableRange(); - let editorPosition = editor.getPosition(); - return editableRange.containsPosition(editorPosition); -} - class ExecCommandCutAction extends ClipboardWritingAction { constructor() { @@ -101,13 +87,6 @@ class ExecCommandCutAction extends ClipboardWritingAction { order: 1 }; } - - public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { - if (!super.enabled(accessor, editor)) { - return false; - } - return editorCursorIsInEditableRange(editor); - } } class ExecCommandCopyAction extends ClipboardWritingAction { @@ -164,13 +143,6 @@ class ExecCommandPasteAction extends ExecCommandAction { order: 3 }; } - - public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { - if (!super.enabled(accessor, editor)) { - return false; - } - return editorCursorIsInEditableRange(editor); - } } if (browser.supportsExecCommand('cut')) { diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts index d7371bea2252187cbccfe0c529668593f07ad651..4c516b446756130fdf4ef026877cdc034c77cba7 100644 --- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts +++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts @@ -29,8 +29,7 @@ import {getDeclarationsAtPosition} from 'vs/editor/contrib/goToDeclaration/commo import {ReferencesController} from 'vs/editor/contrib/referenceSearch/browser/referencesController'; import {ReferencesModel} from 'vs/editor/contrib/referenceSearch/browser/referencesModel'; import {IDisposable, dispose} from 'vs/base/common/lifecycle'; -import {IPeekViewService} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; -import {optional} from 'vs/platform/instantiation/common/instantiation'; +import {PeekContext} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; import {KbExpr} from 'vs/platform/keybinding/common/keybinding'; import ModeContextKeys = editorCommon.ModeContextKeys; @@ -196,7 +195,6 @@ export class OpenDefinitionToSideAction extends DefinitionAction { } export class PeekDefinitionAction extends DefinitionAction { - constructor() { super( 'editor.action.previewDeclaration', @@ -205,7 +203,7 @@ export class PeekDefinitionAction extends DefinitionAction { new DefinitionActionConfig(void 0, true, false) ); - this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasDefinitionProvider); + this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasDefinitionProvider, PeekContext.notInPeekEditor); this.kbOpts = { kbExpr: EditorContextKeys.TextFocus, @@ -219,15 +217,6 @@ export class PeekDefinitionAction extends DefinitionAction { kbExpr: ModeContextKeys.hasDefinitionProvider }; } - - public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { - if (!super.enabled(accessor, editor)) { - return false; - } - - const peekViewService = accessor.get(IPeekViewService, optional); - return (!peekViewService || !peekViewService.isActive); - } } // --- Editor Contribution to goto definition using the mouse and a modifier key diff --git a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts index 5811c18e1a088e274e2c32c2201cbda1ea1dba00..8a9e704fd71f923b98d2d372ff676c4866ff1876 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts @@ -17,10 +17,9 @@ import {Position} from 'vs/editor/common/core/position'; import {Range} from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; import {ServicesAccessor, EditorAction, CommonEditorRegistry} from 'vs/editor/common/editorCommonExtensions'; -import {Location, ReferenceProviderRegistry} from 'vs/editor/common/modes'; -import {IPeekViewService, getOuterEditor} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; +import {Location} from 'vs/editor/common/modes'; +import {IPeekViewService, PeekContext, getOuterEditor} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; import {provideReferences} from '../common/referenceSearch'; -import {ReferenceWidget} from './referencesWidget'; import {ReferencesController, RequestOptions, ctxReferenceSearchVisible} from './referencesController'; import {ReferencesModel} from './referencesModel'; @@ -43,7 +42,7 @@ export class ReferenceController implements editorCommon.IEditorContribution { @optional(IPeekViewService) peekViewService: IPeekViewService ) { if (peekViewService) { - peekViewService.contextKey.bindTo(keybindingService); + PeekContext.inPeekEditor.bindTo(keybindingService); } } @@ -65,7 +64,7 @@ export class ReferenceAction extends EditorAction { false ); - this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasReferenceProvider); + this._precondition = KbExpr.and(EditorContextKeys.TextFocus, ModeContextKeys.hasReferenceProvider, PeekContext.notInPeekEditor); this.kbOpts = { kbExpr: EditorContextKeys.TextFocus, @@ -79,18 +78,6 @@ export class ReferenceAction extends EditorAction { }; } - public enabled(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): boolean { - if (!super.enabled(accessor, editor)) { - return false; - } - const peekViewService = accessor.get(IPeekViewService, optional); - if (peekViewService && peekViewService.isActive) { - return false; - } - - return ReferenceProviderRegistry.has(editor.getModel()); - } - public run(accessor:ServicesAccessor, editor:editorCommon.ICommonCodeEditor): void { let range = editor.getSelection(); let model = editor.getModel(); @@ -187,6 +174,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: CommonEditorRegistry.commandWeight(-101), primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape], - when: KbExpr.and(ReferenceWidget.INNER_EDITOR_CONTEXT_KEY, KbExpr.not('config.editor.stablePeek')), + when: KbExpr.and(PeekContext.inPeekEditor, KbExpr.not('config.editor.stablePeek')), handler: closeActiveReferenceSearch }); diff --git a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts index e82a1598923fb68bf5816656d3defc75d6ef38b7..c67a06ba1bf3d0668b3ca0dbaa2c4b7e0756a265 100644 --- a/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts +++ b/src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts @@ -38,7 +38,6 @@ import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {EmbeddedCodeEditorWidget} from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; import {PeekViewWidget, IPeekViewService} from 'vs/editor/contrib/zoneWidget/browser/peekViewWidget'; import {FileReferences, OneReference, ReferencesModel} from './referencesModel'; -import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; class DecorationsManager implements IDisposable { @@ -485,8 +484,6 @@ export interface SelectionEvent { */ export class ReferenceWidget extends PeekViewWidget { - public static INNER_EDITOR_CONTEXT_KEY = new KbCtxKey('inReferenceSearchEditor', true); - private _model: ReferencesModel; private _decorationsManager: DecorationsManager; @@ -508,7 +505,7 @@ export class ReferenceWidget extends PeekViewWidget { private _contextService: IWorkspaceContextService, private _instantiationService: IInstantiationService ) { - super(editor, ReferenceWidget.INNER_EDITOR_CONTEXT_KEY, { frameColor: '#007ACC', showFrame: false, showArrow: true, isResizeable: true }); + super(editor, { frameColor: '#007ACC', showFrame: false, showArrow: true, isResizeable: true }); this._instantiationService = this._instantiationService.createChild(new ServiceCollection([IPeekViewService, this])); this.create(); diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts index 541aaccfd8a92a26cf9cd05a66bce60a2c0a36b3..7826ed8617e8f9c0419329a8b94c368f0b81d7a8 100644 --- a/src/vs/editor/contrib/rename/browser/rename.ts +++ b/src/vs/editor/contrib/rename/browser/rename.ts @@ -19,7 +19,6 @@ import {ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} fro import {EditorBrowserRegistry} from 'vs/editor/browser/editorBrowserExtensions'; import {IRange, ICommonCodeEditor, EditorContextKeys, ModeContextKeys, IEditorContribution} from 'vs/editor/common/editorCommon'; import {BulkEdit, createBulkEdit} from 'vs/editor/common/services/bulkEdit'; -import {RenameProviderRegistry} from 'vs/editor/common/modes'; import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {rename} from '../common/rename'; import RenameInputField from './renameInputField'; @@ -170,13 +169,6 @@ export class RenameAction extends EditorAction { }; } - public enabled(accessor:ServicesAccessor, editor:ICommonCodeEditor): boolean { - if (!super.enabled(accessor, editor)) { - return false; - } - return RenameProviderRegistry.has(editor.getModel()); - } - public run(accessor:ServicesAccessor, editor:ICommonCodeEditor): TPromise { return RenameController.get(editor).run(); } diff --git a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts index 5cd8f6a2fef6d919d286c224ef2d652da40160fe..5d7a1077736b0581dd52ce9784248fe4b768c691 100644 --- a/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts +++ b/src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts @@ -19,14 +19,20 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService'; import {ICodeEditor} from 'vs/editor/browser/editorBrowser'; import {IOptions, ZoneWidget} from './zoneWidget'; import {EmbeddedCodeEditorWidget} from 'vs/editor/browser/widget/embeddedCodeEditorWidget'; -import {KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; +import {KbExpr, KbCtxKey} from 'vs/platform/keybinding/common/keybinding'; export var IPeekViewService = createDecorator('peekViewService'); +export namespace PeekContext { + export const inPeekEditor = new KbCtxKey('inReferenceSearchEditor', true); + export const notInPeekEditor:KbExpr = inPeekEditor.toNegated(); +} + +export const NOT_INNER_EDITOR_CONTEXT_KEY = new KbCtxKey('inReferenceSearchEditor', true); + export interface IPeekViewService { _serviceBrand: any; isActive: boolean; - contextKey: KbCtxKey; } export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCodeEditor { @@ -37,10 +43,9 @@ export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCo return editor; } -export class PeekViewWidget extends ZoneWidget implements IPeekViewService { +export abstract class PeekViewWidget extends ZoneWidget implements IPeekViewService { public _serviceBrand: any; - public contextKey: KbCtxKey; private _onDidClose = new Emitter(); private _isActive = false; @@ -52,9 +57,8 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService { protected _actionbarWidget: ActionBar; protected _bodyElement: HTMLDivElement; - constructor(editor: ICodeEditor, contextKey: KbCtxKey, options: IOptions = {}) { + constructor(editor: ICodeEditor, options: IOptions = {}) { super(editor, options); - this.contextKey = contextKey; } public dispose(): void { diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index c2da6fc39976ade647dabef237d1fc484b03cf14..5f2944a281b88687c0f43ccaf6f68b3f1cd1f249 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -2759,7 +2759,7 @@ declare module monaco.editor { label: string; alias: string; enabled: boolean; - isSupported(): boolean; + isSupported(forceEditorTextFocus: boolean): boolean; run(): Promise; } diff --git a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts index 7aeb5a0febba78be72f6618e78ddb7eadf5ff26a..4e3bd4712739c731412800a6da4e72e5a351322a 100644 --- a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts +++ b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts @@ -186,9 +186,14 @@ export abstract class AbstractKeybindingService { return new ScopedKeybindingService(this, this._onDidChangeContextKey, domNode); } - public contextMatchesRules(rules: KbExpr): boolean { + public contextMatchesRules(rules: KbExpr, overrideKeys?:any): boolean { const ctx = Object.create(null); this.getContext(this._myContextId).fillInContext(ctx); + if (overrideKeys) { + for (let key in overrideKeys) { + ctx[key] = overrideKeys[key]; + } + } const result = KeybindingResolver.contextMatchesRules(ctx, rules); // console.group(rules.serialize() + ' -> ' + result); // rules.keys().forEach(key => { console.log(key, ctx[key]); }); @@ -257,6 +262,17 @@ export abstract class KeybindingService extends AbstractKeybindingService implem this._commandService = commandService; this._statusService = statusService; this._messageService = messageService; + + // Uncomment this to see the contexts continuously logged + // let lastLoggedValue: string = null; + // setInterval(() => { + // let values = Object.keys(this._contexts).map((key) => this._contexts[key]); + // let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n'); + // if (lastLoggedValue !== logValue) { + // lastLoggedValue = logValue; + // console.log(lastLoggedValue); + // } + // }, 2000); } protected _beginListening(domNode: HTMLElement): void { diff --git a/src/vs/platform/keybinding/common/keybinding.ts b/src/vs/platform/keybinding/common/keybinding.ts index 302014858dad659a657acf8ff3696d9f83b33005..c5d714df52e680b4863fa2931f6d65e528ecacc2 100644 --- a/src/vs/platform/keybinding/common/keybinding.ts +++ b/src/vs/platform/keybinding/common/keybinding.ts @@ -478,7 +478,7 @@ export interface IKeybindingService { onDidChangeContext: Event; createKey(key: string, defaultValue: T): IKeybindingContextKey; - contextMatchesRules(rules: KbExpr): boolean; + contextMatchesRules(rules: KbExpr, overrideKeys?:any): boolean; getContextValue(key: string): T; createScoped(domNode: IKeybindingScopeLocation): IKeybindingService; diff --git a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts index 9c2eb583b57e004cb211bdc0a33a762d3d926d1e..169613bab6f25c89d096a6f9a39e682deb057490 100644 --- a/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/commandsHandler.ts @@ -19,7 +19,7 @@ import {SyncActionDescriptor, ExecuteCommandAction, IMenuService} from 'vs/platf import {IWorkbenchActionRegistry, Extensions as ActionExtensions} from 'vs/workbench/common/actionRegistry'; import {Registry} from 'vs/platform/platform'; import {QuickOpenHandler, QuickOpenAction} from 'vs/workbench/browser/quickopen'; -import {IEditorAction} from 'vs/editor/common/editorCommon'; +import {IEditorAction, IEditor} from 'vs/editor/common/editorCommon'; import {matchesWords, matchesPrefix, matchesContiguousSubString, or} from 'vs/base/common/filters'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; @@ -268,8 +268,11 @@ export class CommandsHandler extends QuickOpenHandler { let activeEditorControl = (activeEditor ? activeEditor.getControl() : null); let editorActions: IEditorAction[] = []; - if (activeEditorControl && types.isFunction(activeEditorControl.getSupportedActions)) { - editorActions = activeEditorControl.getSupportedActions(); + if (activeEditorControl) { + let editor = activeEditorControl; + if (types.isFunction(editor.getSupportedActions)) { + editorActions = editor.getSupportedActions(); + } } let editorEntries = this.editorActionsToEntries(editorActions, searchValue);