Skip to content

Conversation

@marcushoepfner
Copy link
Contributor

Issue: #1002

For more information refer to https://www.compart.com/en/unicode/U+200B To get a ZWSP refer to https://zerowidthspace.me/

@github-actions
Copy link
Contributor

github-actions bot commented Dec 19, 2023

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 c97d0b4. ± Comparison against base commit 875996f.

♻️ This comment has been updated with latest results.

@BeckerWdf
Copy link
Member

BeckerWdf commented Dec 20, 2023

I did a quick manual test on macOS. I found the following issues:

  1. code mining is not displayed emidiately. I have to close and reopen the editor for the code minings to be shown
  2. Two ZWSP next to each other are drawn one the (almost?) same location. See line 4 in:
image
  1. 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".


public class ZeroWidthSpaceLineContentCodeMiningProvider extends AbstractCodeMiningProvider {

private static final char ZWSP_SIGN = '\u200b';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also add

\u200c  zero width non-joiner
\u200d  zero width joiner
\ufeff  zero width no break space

See: https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated this PR.
It works now with all above zero width characters.

Please check it.
Please also check the new preferences:
image

  1. Do we need to distinguish between line begin, end and enclosing for ZWSP? IMHO not, just makes core more complex. But "enclosing" may not fit as a term then.

  2. Do we show ZWSP as code mining or something else? Because it is not just space.

image

@marcushoepfner marcushoepfner force-pushed the zwsp branch 4 times, most recently from b082ac8 to 6cccc08 Compare August 5, 2025 14:06
@marcushoepfner marcushoepfner marked this pull request as draft August 6, 2025 06:21
@marcushoepfner marcushoepfner marked this pull request as ready for review August 13, 2025 06:35
@BeckerWdf
Copy link
Member

I manually tested your change.

the ZWSP is shown correctly:
image

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:
image

Copy link
Member

@BeckerWdf BeckerWdf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments above

@BeckerWdf
Copy link
Member

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:

image

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.

@marcushoepfner
Copy link
Contributor Author

I manually tested your change.

the ZWSP is shown correctly: image

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: image

fixed with the last commit.

@marcushoepfner
Copy link
Contributor Author

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:

image 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

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....

@marcushoepfner marcushoepfner force-pushed the zwsp branch 3 times, most recently from 0ee781a to 8b2948b Compare October 9, 2025 13:27
@BeckerWdf
Copy link
Member

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)

@marcushoepfner marcushoepfner marked this pull request as draft October 13, 2025 05:20
@BeckerWdf
Copy link
Member

fixed with the last commit.

Thanks. That looks good now.

@BeckerWdf
Copy link
Member

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,

@marcushoepfner
Copy link
Contributor Author

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?

@BeckerWdf
Copy link
Member

I tried to ignore and overwrite the color with the one TextEditor uses for drawing spaces, tabs,... According to

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:

@BeckerWdf
Copy link
Member

Is the color of "ZWSP" grey or black in your case?

black.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants