From 7f974f12b4cc884696d1673280afe1e1fae2c25a Mon Sep 17 00:00:00 2001 From: AlexXuChen Date: Fri, 8 Jul 2022 16:09:55 -0400 Subject: [PATCH] Added command to bind qute.inlayHint.enabled to editor.inlayHints.enabled Signed-off-by: AlexXuChen --- src/qute/commands/commandConstants.ts | 5 +++++ src/qute/commands/registerCommands.ts | 15 +++++++++++++++ src/qute/languageServer/settings.ts | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/src/qute/commands/commandConstants.ts b/src/qute/commands/commandConstants.ts index b5bc1270..26b4ebef 100644 --- a/src/qute/commands/commandConstants.ts +++ b/src/qute/commands/commandConstants.ts @@ -39,6 +39,11 @@ export namespace QuteClientCommandConstants { * Client command to execute an XML command on XML Language Server side. */ export const EXECUTE_WORKSPACE_COMMAND = 'qute.workspace.executeCommand'; + + /** + * Bind Qute inlay hint setting to editor inlay hint setting. + */ + export const BIND_QUTE_INLAY_HINT = 'bind.qute.inlayHint.enabled'; } /** diff --git a/src/qute/commands/registerCommands.ts b/src/qute/commands/registerCommands.ts index 50a0d0c7..a3e3c26f 100644 --- a/src/qute/commands/registerCommands.ts +++ b/src/qute/commands/registerCommands.ts @@ -19,6 +19,7 @@ export function registerVSCodeQuteCommands(context: ExtensionContext) { registerJavaDefinitionCommand(context); registerConfigurationUpdateCommand(context); registerQuteValidationToggleCommand(context); + registerQuteInlayHintBindToEditorSetting(context); context.subscriptions.push( workspace.onDidOpenTextDocument((document) => { updateQuteLanguageId(context, document, true); @@ -184,6 +185,20 @@ export function registerConfigurationUpdateCommand(context: ExtensionContext) { })); } +export function registerQuteInlayHintBindToEditorSetting(context: ExtensionContext) { + context.subscriptions.push(commands.registerCommand(QuteClientCommandConstants.BIND_QUTE_INLAY_HINT, async () => { + const editorInlayHintSetting = workspace.getConfiguration().get(`editor.inlayHints.enabled`, "on"); + if (editorInlayHintSetting === "off") { + const edit = { + value: false, + editType: ConfigurationItemEditType.Add, + section: QuteSettings.QUTE_INLAY_HINT + } as ConfigurationItemEdit; + await commands.executeCommand(QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, edit); + } + })); +} + /** * Sets the `editorQuteValidationEnabled` based on `qute.command.validation.template.status` and `qute.validation.enabled`. */ diff --git a/src/qute/languageServer/settings.ts b/src/qute/languageServer/settings.ts index c13027ef..f346e942 100644 --- a/src/qute/languageServer/settings.ts +++ b/src/qute/languageServer/settings.ts @@ -30,6 +30,11 @@ export namespace QuteSettings { */ export const QUTE_OVERRIDE_LANGUAGE_ID = 'qute.templates.override.languageId'; + /** + * Qute inlay hint setting. + */ + export const QUTE_INLAY_HINT = 'qute.inlayHint.enabled'; + export function getQuteTemplatesLanguageMismatch(): QuteTemplateLanguageMismatch { return workspace.getConfiguration().get(QUTE_TEMPLATES_LANGUAGE_MISMATCH); }