IDEA-162844 A simple copy of Default color scheme is flooded with inheritance defining attributes

This commit is contained in:
Vladimir Krivosheev
2016-10-20 17:24:51 +02:00
parent 835c54b8e3
commit 3db867ce03
2 changed files with 18 additions and 13 deletions
@@ -34,10 +34,8 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
}
@Override
public void setAttributes(@NotNull TextAttributesKey key, TextAttributes attributes) {
if (attributes == USE_INHERITED_MARKER || !attributes.equals(getAttributes(key))) {
myAttributesMap.put(key, attributes);
}
public void setAttributes(@NotNull TextAttributesKey key, @NotNull TextAttributes attributes) {
setAttributes(key, attributes, false);
}
public void setAttributes(@NotNull TextAttributesKey key, @NotNull TextAttributes attributes, boolean force) {
@@ -56,17 +54,17 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
@Override
public TextAttributes getAttributes(@Nullable TextAttributesKey key) {
if (key != null) {
TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
TextAttributes attributes = getDirectlyDefinedAttributes(key);
if (fallbackKey != null) {
if (attributes != null && attributes != USE_INHERITED_MARKER) {
return attributes;
}
attributes = getFallbackAttributes(fallbackKey);
if (attributes != null && attributes != USE_INHERITED_MARKER) {
return attributes;
}
if (attributes != null) {
return attributes;
TextAttributesKey fallbackKey = key.getFallbackAttributeKey();
if (fallbackKey != null) {
attributes = getFallbackAttributes(fallbackKey);
if (attributes != null) {
return attributes;
}
}
}
return myParentScheme.getAttributes(key);
@@ -841,7 +841,14 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract
}
if (scheme instanceof EditorColorsSchemeImpl) {
((EditorColorsSchemeImpl)scheme).setAttributes(key, isInherited() ? USE_INHERITED_MARKER : getTextAttributes(), !isInherited() && myIsInheritedInitial);
if (!isInherited()) {
((EditorColorsSchemeImpl)scheme).setAttributes(key, getTextAttributes(), myIsInheritedInitial);
}
else if (!myIsInheritedInitial) {
// set only if previously was not inherited (and, so, we must mark it as inherited)
// https://youtrack.jetbrains.com/issue/IDEA-162844
scheme.setAttributes(key, USE_INHERITED_MARKER);
}
}
else {
scheme.setAttributes(key, isInherited() ? USE_INHERITED_MARKER : getTextAttributes());