From 7575afcbfaf17c423cc1382babb99a7982aaef36 Mon Sep 17 00:00:00 2001 From: "xinglong.wangwxl" Date: Fri, 20 Dec 2024 14:26:24 +0800 Subject: [PATCH] feat: support editor action arguments --- .../browser/monaco-contrib/command/command.service.ts | 8 ++++---- packages/editor/src/browser/preference/schema.ts | 10 ++++++++++ packages/i18n/src/common/editor/en-US.ts | 4 ++++ packages/i18n/src/common/editor/zh-CN.ts | 2 ++ .../monaco/src/browser/monaco.context-key.service.ts | 2 ++ .../src/browser/preference-settings.service.ts | 2 ++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/browser/monaco-contrib/command/command.service.ts b/packages/editor/src/browser/monaco-contrib/command/command.service.ts index d79b480da8..50e87f78d3 100644 --- a/packages/editor/src/browser/monaco-contrib/command/command.service.ts +++ b/packages/editor/src/browser/monaco-contrib/command/command.service.ts @@ -408,10 +408,10 @@ export class MonacoActionRegistry implements IMonacoActionRegistry { */ protected newActionHandler(id: string): MonacoEditorCommandHandler { return { - execute: (editor) => { + execute: (editor, ...args) => { const action = editor.getAction(id); if (action && action.isSupported()) { - return this.runAction(id, editor); + return this.runAction(id, editor, ...args); } }, }; @@ -422,11 +422,11 @@ export class MonacoActionRegistry implements IMonacoActionRegistry { * @param id 要执行的 action * @param editor 执行 action 的 editor,默认为当前 editor */ - protected runAction(id: string, editor: ICodeEditor): Promise { + protected runAction(id: string, editor: ICodeEditor, ...args: any[]): Promise { if (editor) { const action = editor.getAction(id); if (action) { - return action.run(); + return action.run(...args); } } diff --git a/packages/editor/src/browser/preference/schema.ts b/packages/editor/src/browser/preference/schema.ts index eb1d3dbbd5..833a626d0c 100644 --- a/packages/editor/src/browser/preference/schema.ts +++ b/packages/editor/src/browser/preference/schema.ts @@ -1446,6 +1446,16 @@ const monacoEditorSchema: PreferenceSchemaProperties = { default: true, description: '%editor.configuration.unicodeHighlight.ambiguousCharacters%', }, + 'editor.unicodeHighlight.allowedCharacters': { + type: 'object', + default: {}, + description: '%editor.configuration.unicodeHighlight.allowedCharacters%', + }, + 'editor.unicodeHighlight.allowedLocales': { + type: 'object', + default: {}, + description: '%editor.configuration.unicodeHighlight.allowedLocales%', + }, 'diffEditor.renderIndicators': { type: 'boolean', default: DIFF_EDITOR_DEFAULTS.renderIndicators, diff --git a/packages/i18n/src/common/editor/en-US.ts b/packages/i18n/src/common/editor/en-US.ts index fbd0dd8d70..896b9d4b20 100644 --- a/packages/i18n/src/common/editor/en-US.ts +++ b/packages/i18n/src/common/editor/en-US.ts @@ -1,3 +1,7 @@ export const editorLocalizations = { 'editor.format.preferredFormatterNotFound': 'Preferred formatter {0} not found for {1}', + 'editor.configuration.unicodeHighlight.allowedCharacters': + 'Defines allowed characters that are not being highlighted.', + 'editor.configuration.unicodeHighlight.allowedLocales': + 'Unicode characters that are common in allowed locales are not being highlighted.', }; diff --git a/packages/i18n/src/common/editor/zh-CN.ts b/packages/i18n/src/common/editor/zh-CN.ts index 415467e52d..d3ce8dc55d 100644 --- a/packages/i18n/src/common/editor/zh-CN.ts +++ b/packages/i18n/src/common/editor/zh-CN.ts @@ -1,3 +1,5 @@ export const editorLocalizations = { 'editor.format.preferredFormatterNotFound': '未找到 {1} 的首选格式化程序 {0}', + 'editor.configuration.unicodeHighlight.allowedCharacters': '定义不被高亮显示的允许字符', + 'editor.configuration.unicodeHighlight.allowedLocales': '在允许的区域中常见的Unicode字符不会被高亮显示', }; diff --git a/packages/monaco/src/browser/monaco.context-key.service.ts b/packages/monaco/src/browser/monaco.context-key.service.ts index fcd198a886..66024361fe 100644 --- a/packages/monaco/src/browser/monaco.context-key.service.ts +++ b/packages/monaco/src/browser/monaco.context-key.service.ts @@ -61,6 +61,8 @@ export class ConfigurationService extends Disposable implements IConfigurationSe this.preferenceService.onPreferencesChanged(this.triggerPreferencesChanged, this, this.disposables); const monacoConfigService = StandaloneServices.get(IConfigurationService); monacoConfigService.getValue = this.getValue.bind(this); + monacoConfigService.updateValue = this.updateValue.bind(this); + monacoConfigService.inspect = this.inspect.bind(this); } public keys() { diff --git a/packages/preferences/src/browser/preference-settings.service.ts b/packages/preferences/src/browser/preference-settings.service.ts index ae1b380836..207fc041cd 100644 --- a/packages/preferences/src/browser/preference-settings.service.ts +++ b/packages/preferences/src/browser/preference-settings.service.ts @@ -731,6 +731,8 @@ export const defaultSettingSections: { }, { id: 'workbench.editorAssociations' }, { id: 'editor.unicodeHighlight.ambiguousCharacters' }, + { id: 'editor.unicodeHighlight.allowedCharacters' }, + { id: 'editor.unicodeHighlight.allowedLocales' }, ], }, {