diff --git a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java index 6a2eabb94b75..6236708ab912 100644 --- a/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java +++ b/platform/core-api/src/com/intellij/openapi/editor/markup/TextAttributes.java @@ -32,6 +32,8 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { public static final TextAttributes ERASE_MARKER = new TextAttributes(); + private boolean myEnforcedDefaults = false; + /** * Merges (layers) the two given text attributes. * @@ -175,6 +177,10 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { return getForegroundColor() == null && getBackgroundColor() == null && getEffectColor() == null && getFontType() == Font.PLAIN; } + public boolean isFallbackEnabled() { + return isEmpty() && !myEnforcedDefaults; + } + public void reset() { setForegroundColor(null); setBackgroundColor(null); @@ -251,6 +257,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { public TextAttributes clone() { TextAttributes cloned = new TextAttributes(); cloned.myAttrs = myAttrs; + cloned.myEnforcedDefaults = myEnforcedDefaults; return cloned; } @@ -276,6 +283,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable { ext.EFFECT_COLOR, ext.getEffectType(), ext.ERROR_STRIPE_COLOR); + if (isEmpty()) myEnforcedDefaults = true; } @Override diff --git a/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java b/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java index 96f830c78221..482a91f90240 100644 --- a/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java +++ b/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java @@ -28,7 +28,7 @@ public class DefaultLanguageHighlighterColors { public final static TextAttributesKey TEMPLATE_LANGUAGE_COLOR = TextAttributesKey.createTextAttributesKey("DEFAULT_TEMPLATE_LANGUAGE_COLOR", HighlighterColors.TEXT); public final static TextAttributesKey IDENTIFIER = - TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER"); + TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER", HighlighterColors.TEXT); public final static TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("DEFAULT_NUMBER"); public final static TextAttributesKey KEYWORD = 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 c195be03040a..07feda12dc6c 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 @@ -815,7 +815,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract @Override public boolean isInherited() { - return myFallbackAttributes != null && getTextAttributes().isEmpty(); + return myFallbackAttributes != null && getTextAttributes().isFallbackEnabled(); } @Nullable diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 9e4da4acba34..9c60d5a6b7d4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -442,7 +442,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { } private boolean haveToWrite(final TextAttributesKey key, final TextAttributes value, final TextAttributes defaultAttribute) { - if (key.getFallbackAttributeKey() != null && value.isEmpty()) return false; + if (key.getFallbackAttributeKey() != null && value.isFallbackEnabled()) return false; boolean hasDefaultValue = value.equals(defaultAttribute); if (myParentScheme == null) return !hasDefaultValue; return true; @@ -559,7 +559,7 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { if (fallbackKey == null) return null; if (myAttributesMap.containsKey(fallbackKey)) { TextAttributes fallbackAttributes = myAttributesMap.get(fallbackKey); - if (fallbackAttributes != null && (!fallbackAttributes.isEmpty() || fallbackKey.getFallbackAttributeKey() == null)) { + if (fallbackAttributes != null && (!fallbackAttributes.isFallbackEnabled() || fallbackKey.getFallbackAttributeKey() == null)) { return fallbackAttributes; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java index 4d5e65d279a6..4bc634e9797d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/EditorColorsSchemeImpl.java @@ -60,12 +60,9 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte if (attributes != null) return attributes; } else { - if (attributes != null && !attributes.isEmpty()) return attributes; + if (attributes != null && !attributes.isFallbackEnabled()) return attributes; attributes = getFallbackAttributes(fallbackKey); if (attributes != null) return attributes; - if (myParentScheme instanceof DefaultColorsScheme && !DEFAULT_SCHEME_NAME.equals(getName())) { - return null; - } } } return myParentScheme.getAttributes(key);