diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index 008986aee6c1..c179a03cadec 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -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); diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index 5dba2da46dac..a225d6c0930a 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -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());