Add the possibility to define context keys on CodeEditorWidgets

pull/236685/head
Alex Dima 2024-12-20 11:01:48 +01:00
parent 5385e31b3f
commit 91ced52bc8
No known key found for this signature in database
GPG Key ID: 4FA498B1FFF19E4D
1 changed files with 11 additions and 0 deletions

View File

@ -290,6 +290,11 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
}));
this._contextKeyService = this._register(contextKeyService.createScoped(this._domElement));
if (codeEditorWidgetOptions.contextKeyValues) {
for (const [key, value] of Object.entries(codeEditorWidgetOptions.contextKeyValues)) {
this._contextKeyService.createKey(key, value);
}
}
this._notificationService = notificationService;
this._codeEditorService = codeEditorService;
this._commandService = commandService;
@ -1988,6 +1993,12 @@ export interface ICodeEditorWidgetOptions {
* Defaults to MenuId.SimpleEditorContext or MenuId.EditorContext depending on whether the widget is simple.
*/
contextMenuId?: MenuId;
/**
* Define extra context keys that will be defined in the context service
* for the editor.
*/
contextKeyValues?: Record<string, ContextKeyValue>;
}
class ModelData {