From bf571336d48be232e833ec194918932d09b96d7e Mon Sep 17 00:00:00 2001 From: Sergey Pak Date: Wed, 10 Jul 2024 14:49:07 +0200 Subject: [PATCH] fixup! IJPL-13064 Don't apply an incompatible color scheme during settings sync GitOrigin-RevId: d784506891173a64ae9a0fbe9297dffc4dae63c4 --- .../colors/impl/EditorColorsManagerImpl.kt | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt index 2e9c977b50fb..d52687919471 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsManagerImpl.kt @@ -379,7 +379,17 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S override fun getActiveVisibleScheme(): EditorColorsScheme? { val scheme = schemeManager.activeScheme if (scheme is AbstractColorsScheme && !scheme.isReadOnly && !scheme.isVisible) { - return scheme.parentScheme + return when (val parentScheme = scheme.parentScheme) { + null -> { + LOG.error("Parent scheme for '${scheme.name}' is null!") + null + } + is DefaultColorsScheme -> getScheme(parentScheme.editableCopyName) + else -> { + LOG.error("Color scheme '${parentScheme.name}' is not a DefaultColorsScheme!") + null + } + } } return scheme?.let { getEditableCopy(it) } ?: scheme } @@ -525,10 +535,12 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S private inner class EditorColorSchemeProcessor( private val additionalTextAttributes: MutableMap>, ) : LazySchemeProcessor(), SchemeExtensionProvider { - override fun createScheme(dataHolder: SchemeDataHolder, - name: String, - attributeProvider: (String) -> String?, - isBundled: Boolean): EditorColorsSchemeImpl { + override fun createScheme( + dataHolder: SchemeDataHolder, + name: String, + attributeProvider: (String) -> String?, + isBundled: Boolean, + ): EditorColorsSchemeImpl { // do we have BundledEditorColorScheme here? val scheme = if (isBundled) BundledEditorColorScheme(name) else EditorColorsSchemeImpl(null) // todo be lazy @@ -554,9 +566,11 @@ class EditorColorsManagerImpl @NonInjectable constructor(schemeManagerFactory: S return if (scheme.isReadOnly) SchemeState.NON_PERSISTENT else SchemeState.POSSIBLY_CHANGED } - override fun onCurrentSchemeSwitched(oldScheme: EditorColorsScheme?, - newScheme: EditorColorsScheme?, - processChangeSynchronously: Boolean) { + override fun onCurrentSchemeSwitched( + oldScheme: EditorColorsScheme?, + newScheme: EditorColorsScheme?, + processChangeSynchronously: Boolean, + ) { // the method receives the base scheme as the argument, but the actual scheme might be different val actualNewScheme = if (schemeManager.activeScheme == newScheme) { activeVisibleScheme @@ -770,8 +784,10 @@ fun readEditorSchemeNameFromXml(parser: XMLStreamReader): String? { private val BUNDLED_EP_NAME = ExtensionPointName("com.intellij.bundledColorScheme") @VisibleForTesting -fun createLoadBundledSchemeRequests(additionalTextAttributes: MutableMap>, - checkId: Boolean = false) +fun createLoadBundledSchemeRequests( + additionalTextAttributes: MutableMap>, + checkId: Boolean = false, +) : Sequence> { return sequence { for (item in BUNDLED_EP_NAME.filterableLazySequence()) {