Show ZWSP (zero with space) as code mining
Issue: https://github.com/eclipse-platform/eclipse.platform.ui/issues/1002
For more information refer to https://www.compart.com/en/unicode/U+200B To get a ZWSP refer to https://zerowidthspace.me/
Test Results
0 files - 3 018 0 suites - 3 018 0s ⏱️ - 2h 13m 29s 0 tests - 8 226 0 ✅ - 7 977 0 💤 - 249 0 ❌ ±0 0 runs - 23 598 0 ✅ - 22 804 0 💤 - 794 0 ❌ ±0
Results for commit c97d0b4b. ± Comparison against base commit 875996f4.
:recycle: This comment has been updated with latest results.
I did a quick manual test on macOS. I found the following issues:
-
code mining is not displayed emidiately. I have to close and reopen the editor for the code minings to be shown
-
Two ZWSP next to each other are drawn one the (almost?) same location. See line 4 in:
-
When select the "a" and the "ZWSP" in line 2 from the above screenshot to with the keyboard I have to press the right-cursor two times until the caret is behind the "ZWSP".
I manually tested your change.
the ZWSP is shown correctly:
but when I disable the "show whitespace character" function (e.g. via the toolbar button) the ZWSP code mining still not disappears (even though the other "white space character" stuff does correctly disappear:
another topic: a user can change the color of the code minings in the "fonts and colors" preference page. If you do this you will see a mix of colors:
Maybe this can be improved:
- either by ignoring the users color pref here
- also use the code mining color from preferences for the other "white space character" drawing logic.
I manually tested your change.
the ZWSP is shown correctly:
but when I disable the "show whitespace character" function (e.g. via the toolbar button) the ZWSP code mining still not disappears (even though the other "white space character" stuff does correctly disappear:
fixed with the last commit.
another topic: a user can change the color of the code minings in the "fonts and colors" preference page. If you do this you will see a mix of colors:
Maybe this can be improved:
- either by ignoring the users color pref here
- also use the code mining color from preferences for the other "white space character" drawing logic.
I tried to ignore and overwrite the color with the one TextEditor uses for drawing spaces, tabs,...
According to https://github.com/eclipse-platform/eclipse.platform.ui/blob/2c5b6056f00e7a012022aa8f5342ed5f97e5a6c1/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/WhitespaceCharacterPainter.java#L447 this is SWT.COLOR_LIST_FOREGROUND, which is black.
I even debugged the drawing of a tab and it was colored 0, 0, 0 but appeared grey. I dont get it....
I just played around a bit with the current state. I got this:
java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Display.getSystemColor(int)" because the return value of "org.eclipse.swt.widgets.Display.getCurrent()" is null
at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMining.<init>(ZeroWidthCharactersLineContentCodeMining.java:40)
at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.createCodeMining(ZeroWidthCharactersLineContentCodeMiningProvider.java:108)
at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.provideCodeMinings(ZeroWidthCharactersLineContentCodeMiningProvider.java:72)
at org.eclipse.jface.internal.text.codemining.CodeMiningManager.lambda$2(CodeMiningManager.java:194)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
fixed with the last commit.
Thanks. That looks good now.
I just played around a bit with the current state. I got this:
java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Display.getSystemColor(int)" because the return value of "org.eclipse.swt.widgets.Display.getCurrent()" is null at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMining.<init>(ZeroWidthCharactersLineContentCodeMining.java:40) at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.createCodeMining(ZeroWidthCharactersLineContentCodeMiningProvider.java:108) at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.provideCodeMinings(ZeroWidthCharactersLineContentCodeMiningProvider.java:72) at org.eclipse.jface.internal.text.codemining.CodeMiningManager.lambda$2(CodeMiningManager.java:194) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
This is now also fixed. Thanks,
I just played around a bit with the current state. I got this:
java.lang.NullPointerException: Cannot invoke "org.eclipse.swt.widgets.Display.getSystemColor(int)" because the return value of "org.eclipse.swt.widgets.Display.getCurrent()" is null at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMining.<init>(ZeroWidthCharactersLineContentCodeMining.java:40) at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.createCodeMining(ZeroWidthCharactersLineContentCodeMiningProvider.java:108) at org.eclipse.ui.internal.texteditor.codemining.ZeroWidthCharactersLineContentCodeMiningProvider.provideCodeMinings(ZeroWidthCharactersLineContentCodeMiningProvider.java:72) at org.eclipse.jface.internal.text.codemining.CodeMiningManager.lambda$2(CodeMiningManager.java:194) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)This is now also fixed. Thanks,
Is the color of "ZWSP" grey or black in your case?
I tried to ignore and overwrite the color with the one TextEditor uses for drawing spaces, tabs,... According to
https://github.com/eclipse-platform/eclipse.platform.ui/blob/2c5b6056f00e7a012022aa8f5342ed5f97e5a6c1/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/WhitespaceCharacterPainter.java#L447
this is
SWT.COLOR_LIST_FOREGROUND, which is black. I even debugged the drawing of a tab and it was colored 0, 0, 0 but appeared grey. I dont get it....
I also just debugged this. And I see that the color (for the whitespace chars comes from the styleRange not the textWidget:
https://github.com/eclipse-platform/eclipse.platform.ui/blob/2c5b6056f00e7a012022aa8f5342ed5f97e5a6c1/bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/WhitespaceCharacterPainter.java#L449
Is the color of "ZWSP" grey or black in your case?
black.


Maybe this can be improved: