Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support editor action arguments #4254

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
},
};
Expand All @@ -422,11 +422,11 @@ export class MonacoActionRegistry implements IMonacoActionRegistry {
* @param id 要执行的 action
* @param editor 执行 action 的 editor,默认为当前 editor
*/
protected runAction(id: string, editor: ICodeEditor): Promise<void> {
protected runAction(id: string, editor: ICodeEditor, ...args: any[]): Promise<void> {
if (editor) {
const action = editor.getAction(id);
if (action) {
return action.run();
return action.run(...args);
}
}

Expand Down
10 changes: 10 additions & 0 deletions packages/editor/src/browser/preference/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions packages/i18n/src/common/editor/en-US.ts
Original file line number Diff line number Diff line change
@@ -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.',
};
2 changes: 2 additions & 0 deletions packages/i18n/src/common/editor/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const editorLocalizations = {
'editor.format.preferredFormatterNotFound': '未找到 {1} 的首选格式化程序 {0}',
'editor.configuration.unicodeHighlight.allowedCharacters': '定义不被高亮显示的允许字符',
'editor.configuration.unicodeHighlight.allowedLocales': '在允许的区域中常见的Unicode字符不会被高亮显示',
};
2 changes: 2 additions & 0 deletions packages/monaco/src/browser/monaco.context-key.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ export const defaultSettingSections: {
},
{ id: 'workbench.editorAssociations' },
{ id: 'editor.unicodeHighlight.ambiguousCharacters' },
{ id: 'editor.unicodeHighlight.allowedCharacters' },
{ id: 'editor.unicodeHighlight.allowedLocales' },
],
},
{
Expand Down
Loading