Add activeCustomEditorId context
Fixes #113511 This tracks the id of the currently active custom editor This change also removes the 'customEditors' context. This was an old context specific to custom editors and has since been replaced by the more generic `activeEditorAvailableEditorIds` context
This commit is contained in:
parent
e3829dc247
commit
623741272a
|
@ -55,12 +55,12 @@
|
|||
"commandPalette": [
|
||||
{
|
||||
"command": "imagePreview.zoomIn",
|
||||
"when": "imagePreviewFocus",
|
||||
"when": "customEditor == 'imagePreview.previewEditor'",
|
||||
"group": "1_imagePreview"
|
||||
},
|
||||
{
|
||||
"command": "imagePreview.zoomOut",
|
||||
"when": "imagePreviewFocus",
|
||||
"when": "customEditor == 'imagePreview.previewEditor'",
|
||||
"group": "1_imagePreview"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -24,7 +24,7 @@ import { EditorsAssociations, editorsAssociationsSettingId, Extensions as Editor
|
|||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { EditorInput, EditorOptions, Extensions as EditorInputExtensions, GroupIdentifier, IEditorInput, IEditorInputFactoryRegistry, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { CONTEXT_CUSTOM_EDITORS, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, CustomEditorPriority, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
import { CONTEXT_ACTIVE_CUSTOM_EDITOR_ID, CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE, CustomEditorCapabilities, CustomEditorInfo, CustomEditorInfoCollection, CustomEditorPriority, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
import { CustomEditorModelManager } from 'vs/workbench/contrib/customEditor/common/customEditorModelManager';
|
||||
import { IWebviewService } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
|
@ -41,7 +41,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
|
|||
|
||||
private readonly _models = new CustomEditorModelManager();
|
||||
|
||||
private readonly _customEditorContextKey: IContextKey<string>;
|
||||
private readonly _activeCustomEditorId: IContextKey<string>;
|
||||
private readonly _focusedCustomEditorIsEditable: IContextKey<boolean>;
|
||||
|
||||
private readonly _onDidChangeEditorTypes = this._register(new Emitter<void>());
|
||||
|
@ -62,7 +62,7 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
|
|||
) {
|
||||
super();
|
||||
|
||||
this._customEditorContextKey = CONTEXT_CUSTOM_EDITORS.bindTo(contextKeyService);
|
||||
this._activeCustomEditorId = CONTEXT_ACTIVE_CUSTOM_EDITOR_ID.bindTo(contextKeyService);
|
||||
this._focusedCustomEditorIsEditable = CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE.bindTo(contextKeyService);
|
||||
|
||||
this._contributedEditors = this._register(new ContributedCustomEditors(storageService));
|
||||
|
@ -230,14 +230,12 @@ export class CustomEditorService extends Disposable implements ICustomEditorServ
|
|||
const activeEditorPane = this.editorService.activeEditorPane;
|
||||
const resource = activeEditorPane?.input?.resource;
|
||||
if (!resource) {
|
||||
this._customEditorContextKey.reset();
|
||||
this._activeCustomEditorId.reset();
|
||||
this._focusedCustomEditorIsEditable.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
const possibleEditors = this.getAllCustomEditors(resource).allEditors;
|
||||
|
||||
this._customEditorContextKey.set(possibleEditors.map(x => x.id).join(','));
|
||||
this._activeCustomEditorId.set(activeEditorPane?.input instanceof CustomEditorInput ? activeEditorPane.input.viewType : '');
|
||||
this._focusedCustomEditorIsEditable.set(activeEditorPane?.input instanceof CustomEditorInput);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,15 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
|
|||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { GroupIdentifier, IEditorInput, IEditorPane, IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
export const ICustomEditorService = createDecorator<ICustomEditorService>('customEditorService');
|
||||
|
||||
export const CONTEXT_CUSTOM_EDITORS = new RawContextKey<string>('customEditors', '');
|
||||
export const CONTEXT_ACTIVE_CUSTOM_EDITOR_ID = new RawContextKey<string>('activeCustomEditorId', '', {
|
||||
type: 'string',
|
||||
description: nls.localize('context.customEditor', "The viewType of the currently active custom editor."),
|
||||
});
|
||||
|
||||
export const CONTEXT_FOCUSED_CUSTOM_EDITOR_IS_EDITABLE = new RawContextKey<boolean>('focusedCustomEditorIsEditable', false);
|
||||
|
||||
export interface CustomEditorCapabilities {
|
||||
|
|
Loading…
Reference in a new issue