From 3bf5ef02c0dc3087fb4cdd0a794892edde359a0d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 8 May 2020 09:28:15 +0200 Subject: Add master config for inlayHints to make disabling easy --- editors/code/package.json | 5 +++++ editors/code/src/config.ts | 1 + editors/code/src/inlay_hints.ts | 14 +++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'editors') diff --git a/editors/code/package.json b/editors/code/package.json index 6935fa7a5..853fc513b 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -300,6 +300,11 @@ "default": true, "markdownDescription": "Check with all features (will be passed as `--all-features`)" }, + "rust-analyzer.inlayHints.enable": { + "type": "boolean", + "default": true, + "description": "Disable all inlay hints" + }, "rust-analyzer.inlayHints.typeHints": { "type": "boolean", "default": true, diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index 110e54180..46de922f3 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts @@ -94,6 +94,7 @@ export class Config { get inlayHints() { return { + enable: this.get("inlayHints.enable"), typeHints: this.get("inlayHints.typeHints"), parameterHints: this.get("inlayHints.parameterHints"), chainingHints: this.get("inlayHints.chainingHints"), diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index a09531797..a2b07d003 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts @@ -10,13 +10,13 @@ export function activateInlayHints(ctx: Ctx) { const maybeUpdater = { updater: null as null | HintsUpdater, async onConfigChange() { - if ( - !ctx.config.inlayHints.typeHints && - !ctx.config.inlayHints.parameterHints && - !ctx.config.inlayHints.chainingHints - ) { - return this.dispose(); - } + const anyEnabled = ctx.config.inlayHints.typeHints + || ctx.config.inlayHints.parameterHints + || ctx.config.inlayHints.chainingHints; + const enabled = ctx.config.inlayHints.enable && anyEnabled; + + if (!enabled) return this.dispose(); + await sleep(100); if (this.updater) { this.updater.syncCacheAndRenderHints(); -- cgit v1.2.3