From 1104736883b41da1b69d1f000204a3b66427f9f2 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 15 Nov 2024 20:16:28 +0100 Subject: [PATCH] bugfix: Check if inlay hints refresh is enabled Fixes https://github.com/scalameta/metals/issues/6937 --- .../scala/meta/internal/metals/ClientConfiguration.scala | 9 +++++++++ .../clients/language/ConfiguredLanguageClient.scala | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala b/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala index efb57a805f5..1e444677271 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ClientConfiguration.scala @@ -162,6 +162,15 @@ final class ClientConfiguration( } yield true }.getOrElse(false) + def isInlayHintsRefreshEnabled(): Boolean = { + for { + capabilities <- clientCapabilities + workspace <- Option(capabilities.getWorkspace()) + inlayHints <- Option(workspace.getInlayHint()) + refreshSupport <- Option(inlayHints.getRefreshSupport()) + } yield refreshSupport.booleanValue() + }.getOrElse(false) + def hoverContentType(): ContentType = (for { capabilities <- clientCapabilities diff --git a/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala b/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala index 1c11679a178..3f13e88d13c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/clients/language/ConfiguredLanguageClient.scala @@ -140,7 +140,10 @@ final class ConfiguredLanguageClient( } override def refreshInlayHints(): CompletableFuture[Void] = { - if (clientConfig.isInlayHintsEnabled()) { + if ( + clientConfig.isInlayHintsEnabled() && clientConfig + .isInlayHintsRefreshEnabled() + ) { underlying .refreshInlayHints() .handle { (msg, ex) =>