diff --git a/platform/core-api/src/com/intellij/openapi/util/registry/EarlyAccessRegistryManager.kt b/platform/core-api/src/com/intellij/openapi/util/registry/EarlyAccessRegistryManager.kt index 1c3b36e9f6b8..252a8531b8f8 100644 --- a/platform/core-api/src/com/intellij/openapi/util/registry/EarlyAccessRegistryManager.kt +++ b/platform/core-api/src/com/intellij/openapi/util/registry/EarlyAccessRegistryManager.kt @@ -113,6 +113,15 @@ object EarlyAccessRegistryManager { saveConfigFile(map, configFile) { map.get(it) } } + /** + * Updates value for registry property which may be accessed via this class. + * Use this function instead of the default [RegistryValue.setValue] to ensure that the updated value will be saved to [fileName]. + */ + fun setBoolean(key: String, value: Boolean) { + lazyMap.value[key] = value.toString() + ApplicationManager.getApplication().serviceIfCreated()?.get(key)?.setValue(value) + } + fun syncAndFlush() { // Why do we sync? get (not yet loaded) -> not changed by a user but actually in a registry -> no explicit put // Why maybe in a registry but not in our store? diff --git a/platform/lang-impl/src/com/intellij/ui/ExperimentalUIImpl.kt b/platform/lang-impl/src/com/intellij/ui/ExperimentalUIImpl.kt index d97a1aa2b0ea..9b1d303e0ebf 100644 --- a/platform/lang-impl/src/com/intellij/ui/ExperimentalUIImpl.kt +++ b/platform/lang-impl/src/com/intellij/ui/ExperimentalUIImpl.kt @@ -19,7 +19,6 @@ import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.ui.MessageDialogBuilder import com.intellij.openapi.ui.Messages import com.intellij.openapi.util.registry.EarlyAccessRegistryManager -import com.intellij.openapi.util.registry.Registry import com.intellij.util.PlatformUtils /** @@ -114,7 +113,7 @@ private class ExperimentalUIImpl : ExperimentalUI() { private fun saveNewValue(enabled: Boolean) { try { logger.info("Saving newUi=$enabled to registry") - Registry.get(KEY).setValue(enabled) + EarlyAccessRegistryManager.setBoolean(KEY, enabled) EarlyAccessRegistryManager.syncAndFlush() } catch (e: Throwable) {