mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-189920 Attribute inheritance flag in Editor color scheme is reverted on Apply
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.editor;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaHighlightingColors;
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
|
||||
import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl;
|
||||
@@ -20,9 +23,8 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Ensures that Java attributes are not affected by changes in EditorColorScheme or these changes are planned and intentional.
|
||||
*/
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
|
||||
public class JavaEditorTextAttributesTest extends LightPlatformTestCase {
|
||||
|
||||
private static List<AttributesDescriptor> getDescriptors() {
|
||||
@@ -107,6 +109,9 @@ public class JavaEditorTextAttributesTest extends LightPlatformTestCase {
|
||||
return dumpBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that Java attributes are not affected by changes in EditorColorScheme or these changes are planned and intentional.
|
||||
*/
|
||||
public void testDefaultColorScheme() {
|
||||
assertEquals(
|
||||
"ABSTRACT_CLASS_NAME_ATTRIBUTES { color: #000000; font-style: normal; }\n" +
|
||||
@@ -211,4 +216,15 @@ public class JavaEditorTextAttributesTest extends LightPlatformTestCase {
|
||||
dumpDefaultColorScheme("Darcula")
|
||||
);
|
||||
}
|
||||
|
||||
public void testInheritanceFlagCanBeOverwrittenWithDefaultAttributes() {
|
||||
EditorColorsScheme defaultScheme = EditorColorsManager.getInstance().getScheme(EditorColorsScheme.DEFAULT_SCHEME_NAME);
|
||||
EditorColorsScheme editorScheme = (EditorColorsScheme)defaultScheme.clone();
|
||||
TextAttributes localVarAttrs = defaultScheme.getAttributes(JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES);
|
||||
editorScheme.setAttributes(JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES, localVarAttrs);
|
||||
TextAttributes changedAttrs = new TextAttributes(Color.BLUE, Color.WHITE, null, EffectType.BOXED, 0);
|
||||
editorScheme.setAttributes(DefaultLanguageHighlighterColors.LOCAL_VARIABLE, changedAttrs);
|
||||
TextAttributes attributes = editorScheme.getAttributes(JavaHighlightingColors.LOCAL_VARIABLE_ATTRIBUTES);
|
||||
assertNotEquals(attributes, changedAttrs);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -51,7 +51,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
|
||||
if (TextAttributesKey.isTemp(key)) {
|
||||
myAttributesTempMap.put(key, attributes);
|
||||
}
|
||||
else if (attributes == INHERITED_ATTRS_MARKER || !Comparing.equal(attributes, getAttributes(key))) {
|
||||
else if (attributes == INHERITED_ATTRS_MARKER || !Comparing.equal(attributes, getDirectlyDefinedAttributes(key))) {
|
||||
myAttributesMap.put(key, attributes);
|
||||
myAttributesTempMap.clear();
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class EditorColorsSchemeImpl extends AbstractColorsScheme implements Exte
|
||||
|
||||
@Override
|
||||
public void setColor(ColorKey key, Color color) {
|
||||
if (color == INHERITED_COLOR_MARKER || !Comparing.equal(color, getColor(key))) {
|
||||
if (color == INHERITED_COLOR_MARKER || !Comparing.equal(color, getDirectlyDefinedColor(key))) {
|
||||
myColorsMap.put(key, ObjectUtils.notNull(color, NULL_COLOR_MARKER));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user