Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 441135

Summary: [Dark Theme] [CSS] Syntax coloring preferences and annotation preferences not persisted on Dark theme
Product: [Eclipse Project] Platform Reporter: Kaspar Thommen <snooper77>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: 2xsarilhos, Brandon_McCulligh, daniel.rolka, daniel_megert, dinghuicong, gautier.desaintmartinlacaze, kashihara, Lars.Vogel, mail, markus.kell.r, ricardo.richard.b, rustyscottweber
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=520512
Whiteboard:
Attachments:
Description Flags
Modified e4-dark_preferencestyle.css none

Description Kaspar Thommen CLA 2014-08-05 03:30:35 EDT
1. Extract eclipse-java-luna-R-win32-x86_64.zip and start Eclipse

2. Go to Window -> Preferences -> General -> Appearance -> Theme -> Dark. Click OK.

3. Create a new Java project and add the following class:

public class Test {
	public static void main(String[] args) {
		int myInt;
	}
}

4. Go to Window -> Preferences -> Java -> Editor -> Syntax Coloring, Element Java, uncheck 'Enable' on 'Local variable declarations' and 'Local variables'

5. Go to Window -> Preferences -> General -> Editors -> Text Editors -> Annotations, select 'Warnings' and select 'Squiggly Line' in 'Text as'

6. Restart Eclipse

7. You'll notice that the 'Local variable declarations' preference got re-enabled, because the 'myInt' variable is orange again, while the 'Local variables' one was persisted.

8. You'll also notice that the 'Warning' annotation has changed back from 'Squiggly Line' to 'Highlighted', because the 'myInt' variable is highlighted again.
Comment 1 Dani Megert CLA 2014-08-05 07:38:42 EDT
Confirmed using R4.4.

Daniel, looks like bug 434485 did not catch all cases.

The annotations are defined in
/org.eclipse.ui.themes/css/dark/e4-dark_preferencestyle.css
Comment 2 Dani Megert CLA 2014-08-08 12:22:50 EDT
*** Bug 441333 has been marked as a duplicate of this bug. ***
Comment 3 Brandon McCulligh CLA 2014-08-25 10:42:26 EDT
Or at least change the default preference back to underlined instead of highlight. This is driving me insane every time I re-open eclipse there are yellow highlights (warnings default) everywhere.
Comment 4 Daniel Rolka CLA 2014-11-19 09:29:05 EST
*** Bug 450898 has been marked as a duplicate of this bug. ***
Comment 5 Daniel Rolka CLA 2014-12-08 09:33:05 EST
The issue is caused by some kind of optimization done by JDT that doesn't store the property in the 'org.eclipse.jdt.ui.prefs' file when it gets the default value. So when i.e. the 'semanticHighlighting.localVariable.enabled' property gets the 'false' value then it gets stored in the preference file and it is fine from the CSS engine's point of view. 
However when it gets 'true' then JDT doesn't store it (or even removes from the property file) and for the CSS engine it is the marker that is it the default value (not modified by user) and it can get overridden with the proper CSS values. After removing the property from the property file there is no information that it gets customized by the user. 

The solution here is to always keep the property in the property file after user's customization. In this way the CSS engine will know that the particular property has been modified by the user and we should skip the overriding by CSS process for such property. 

I will move it to the JDT component since we are not able to fix it on our site - the fix for that should be quite easy.

The  'semanticHighlighting.localVariable.enabled' property gets overridden in the '<ECLIPSE_HOME>/plugins/org.eclipse.jdt.ui_<SPECIFIER>.jar/css/e4-dark_jdt_syntaxhighlighting.css' style sheet 

Daniel
Comment 6 Markus Keller CLA 2014-12-08 11:19:26 EST
(In reply to Daniel Rolka from comment #5)
That sounds like JDT is just following the normal preference storage rules: If a setting is different from the default, then store it. If it's the same as the default, then *remove* the whole setting, so that the user always gets the default value, even if the default gets changed later.

If the dark mode needs different defaults, then it has to set those defaults in the preference store.

Note: If you want to move a bug to an other component, then you also have to update the assignee. Moved the bug back to Platform/UI now.
Comment 7 Daniel Rolka CLA 2014-12-10 07:53:02 EST
(In reply to Markus Keller from comment #6)
> (In reply to Daniel Rolka from comment #5)
> That sounds like JDT is just following the normal preference storage rules:
> If a setting is different from the default, then store it. If it's the same
> as the default, then *remove* the whole setting, so that the user always
> gets the default value, even if the default gets changed later.
> 
> If the dark mode needs different defaults, then it has to set those defaults
> in the preference store.
> 

It is not so simple since I don't know the default value being at the IPreferenceChangeListener listener level. I know only the old and the new values and sorry, but I don't know how to guess the default one basing on it. OK, when the old value was 'true' and the new one is NULL, I can predict that the default will be 'false'. However such assumption is very risky, especially keeping in mind that values of preferences can have any format

OK, we know what is the issue here, but I don't know how to fix it on the Platform UI side at this moment

Daniel
Comment 8 Ricardo Bochnia CLA 2014-12-19 16:29:18 EST
Removing all 'XIndicationHighlighting=true' from e4-dark_preferencestyle.css seems to fix this bug and prevents overriding user settings. I think we should just remove these lines.
Comment 9 Ricardo Bochnia CLA 2014-12-19 16:33:54 EST
Created attachment 249562 [details]
Modified e4-dark_preferencestyle.css
Comment 10 Ricardo Bochnia CLA 2014-12-19 16:37:49 EST
PS: The patch fixes only the issue with annotations, not the one with syntax coloring,
Comment 11 Brandon McCulligh CLA 2015-01-05 11:54:50 EST
Thank you so much for this patch, it fixed the problem. Now I don't fret about closing eclipse.
Comment 12 Russell Weber CLA 2015-02-17 14:57:04 EST
*** Bug 459939 has been marked as a duplicate of this bug. ***
Comment 13 Lars Vogel CLA 2018-05-24 07:24:24 EDT
Is this still an issue with the default CSS preferences?
Comment 14 Lars Vogel CLA 2018-08-23 09:30:06 EDT
(In reply to Lars Vogel from comment #13)
> Is this still an issue with the default CSS preferences?

No reply, marking as works for me.