IJPL-173992 Fix UISettingsState initialization if the application isn't loaded yet

(cherry picked from commit 43e40d182c3cd743d17c11b38498da4fa7c0f2b5)

IJ-CR-152966

GitOrigin-RevId: 305c2ba1b7d5c3245755fd2947eb6d9b42e26276
This commit is contained in:
Dmitry Drobotov
2024-12-25 16:35:36 +01:00
committed by intellij-monorepo-bot
parent 0596355a2e
commit 4748a2cbfc

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.ide.ui
import com.intellij.diagnostic.LoadingState
import com.intellij.idea.AppMode
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.BaseState
@@ -20,6 +21,9 @@ interface UISettingsStateDefaultsProvider {
companion object {
@JvmStatic
fun getInstance(): UISettingsStateDefaultsProvider = ApplicationManager.getApplication().service<UISettingsStateDefaultsProvider>()
@JvmStatic
fun getInstanceOrNull(): UISettingsStateDefaultsProvider? = if (LoadingState.CONFIGURATION_STORE_INITIALIZED.isOccurred) getInstance() else null
}
val searchEverywherePreviewDefault: Boolean
@@ -247,7 +251,8 @@ class UISettingsState : BaseState() {
var showBreakpointsOverLineNumbers: Boolean by property(true)
@get:OptionTag("SHOW_PREVIEW_IN_SEARCH_EVERYWHERE")
var showPreviewInSearchEverywhere: Boolean by property(UISettingsStateDefaultsProvider.getInstance().searchEverywherePreviewDefault)
var showPreviewInSearchEverywhere: Boolean by property(UISettingsStateDefaultsProvider.getInstanceOrNull()?.searchEverywherePreviewDefault
?: false)
@Suppress("FunctionName")
fun _incrementModificationCount(): Unit = incrementModificationCount()