Skip to content

Commit

Permalink
Added command to bind qute.inlayHint.enabled to editor.inlayHints.ena…
Browse files Browse the repository at this point in the history
…bled

Signed-off-by: AlexXuChen <[email protected]>
  • Loading branch information
AlexXuChen authored and Alexander Chen committed Jul 28, 2022
1 parent e9b27ab commit 7f974f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/qute/commands/commandConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/qute/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<string>(`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`.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/qute/languageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuteTemplateLanguageMismatch>(QUTE_TEMPLATES_LANGUAGE_MISMATCH);
}
Expand Down

0 comments on commit 7f974f1

Please sign in to comment.