FIXED IDEA-152156 Unable to save new colors for old existing theme

This commit is contained in:
Rustam Vishnyakov
2016-03-01 16:43:16 +03:00
parent 89dcde70dd
commit c5ea70c7ff
2 changed files with 11 additions and 2 deletions
@@ -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);
}
@@ -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");