From c5ea70c7ff0979b360fe256e85a4d5071a83fb14 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Tue, 1 Mar 2016 16:21:53 +0300 Subject: [PATCH] FIXED IDEA-152156 Unable to save new colors for old existing theme --- .../editor/colors/impl/AbstractColorsScheme.java | 11 ++++++++++- .../colors/impl/EditorColorsSchemeImplTest.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 21aba543141b..530fbfc2962a 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -606,7 +606,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { Element element = new Element(OPTION_ELEMENT); element.setAttribute(NAME_ATTR, key.getExternalName()); if (baseKey != null && value.isFallbackEnabled()) { - if (defaultFallbackAttr != null && defaultAttr != null && defaultAttr != defaultFallbackAttr) { + if (isParentOverwritingInheritance(key)) { element.setAttribute(BASE_ATTRIBUTES_ATTR, baseKey.getExternalName()); attrElements.addContent(element); } @@ -622,6 +622,15 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { } } + private boolean isParentOverwritingInheritance(@NotNull TextAttributesKey key) { + TextAttributes parentAttrs = + myParentScheme instanceof AbstractColorsScheme ? ((AbstractColorsScheme)myParentScheme).getDirectlyDefinedAttributes(key) : null; + if (parentAttrs != null) { + return !parentAttrs.isFallbackEnabled(); + } + return false; + } + protected Color getOwnColor(ColorKey key) { return myColorsMap.get(key); } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java index 2006051a53f4..87f159200272 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImplTest.java @@ -294,7 +294,7 @@ public class EditorColorsSchemeImplTest extends LightPlatformCodeInsightTestCase } @SuppressWarnings("unused") - public void _testIdea152156() throws Exception { + public void testIdea152156() throws Exception { EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME); EditorColorsScheme parentScheme = (EditorColorsScheme)defaultScheme.clone(); parentScheme.setName("DefaultTest");