"Show whitespace" should also show "Zero Width Whitepace"
Source Code (that e.g. was copied from a web page) might contain zero width whitespaces (ZWSP). That this is can be read here; https://en.wikipedia.org/wiki/Zero-width_space#:~:text=The%20zero%2Dwidth%20space%20(%E2%80%8B,but%20after%20which%20there%20may
The "Show Whiteplace" function of the text editor does show whitespaces and line breaks etc. but does not show ZWSPs.
Other editor (e.g. Notepad++ on windows) can show this. See:
I think eclipse should also be capable of showing this.
If you are asking how to enter an ZWSP into your editor: Use this website: https://zerowidthspace.me/
This was already proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=578213
org.eclipse.jface.text.WhitespaceCharacterPainter is the place where the whitespace char drawing happens
This was already proposed in https://bugs.eclipse.org/bugs/show_bug.cgi?id=578213
Can this enhancement to show invisible characters be extended to all Zero width characters as mentioned here ?https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator
Would you like to see this as an option here?
Would you like to see this as an option here?
Yes. Ideally ZWSP proposed by author might come here . Along with this other Zero width characters can be implemented as part of this enhancement.
The responsible java class is WhitespaceCharacterPainter (method drawCharRange).
It seems, that it replaces one character by another, e.g. space by middle dot.
I tried to replace a zero with white space with the letters "ZWSP". But then it looks strange when I continue typing.
This is only the ZWSP pasted from https://zerowidthspace.me/ (it has a width of 0 of course). It looks ok:
But when typing is continued, it looks strange:
ZWSP is invisible space and I have pasted it between letter "e" and "." and Show whitespace characters is off in preferences.
I tried to modify the code so that ZWSP is replaced with \u2588 , but it is drawn on next character as below.. when Show whitespace characters is on in preferences.
Currently Eclipse is supporting all visible characters so that there is space and where new symbol can be drawn but for invisible characters there is no space to draw new symbol . For CR and LF , when text is read to load itself it is read as \r and \n so that it can be easily drawn in this place.
Should we push next available character to make space for it ? so that drawing happens on later stage.. But there are challenges on how to achieve this !
Should we push next available character to make space for it ? so that drawing happens on later stage.. But there are challenges on how to achieve this !
How do other editors handle that challenges?
Should we push next available character to make space for it ? so that drawing happens on later stage.
Maybe we could do it similar like it's done for the code mining. For code minings also content is drawn for which we need to make space in the editor. The difference is that for the code minings we need additional vertical space for the none-width chars we need additional horizontal space.
The difference is that for the code minings we need additional vertical space for the none-width chars we need additional horizontal space.
That's not true. See for example InlinedAnnotationDemo.java from the jface examples. Here the strings "red:", "green:" and "blue:" are drawn inline into the text.
The difference is that for the code minings we need additional vertical space for the none-width chars we need additional horizontal space.
That's not true. See for example InlinedAnnotationDemo.java from the jface examples. Here the strings "red:", "green:" and "blue:" are drawn inline into the text.
Support for this seems to be completely in jface not in SWT.
I think you should indeed consider using InlinedAnnotation for the case of adding "artificial" content in a text line.
I have create a first PR.
Some questions.
-
Is the used plugin the correct sport for this?
-
There is a white space character preference page, the question is, whether we should add ZWSP? In contradiction the white space pref page is about the show white space character functionality which is handled in org.eclipse.jface.text.WhitespaceCharacterPainter, but in my commit code mining is used. But currently there is not Code Mining preference page for text editors itself, just for java editors.
I don't think a new pref is necessary. Relying on the exisying Show whitespaces is enough
- There is a white space character preference page, the question is, whether we should add ZWSP?
I Would say yes.
In contradiction the white space pref page is about the show white space character functionality which is handled in org.eclipse.jface.text.WhitespaceCharacterPainter, but in my commit code mining is used. But currently there is not Code Mining preference page for text editors itself, just for java editors.
But isn't this just an implementation detail. From a user perspective I would say these settings belong together.
I don't think a new pref is necessary. Relying on the exisying Show whitespaces is enough
Ah, the whitespace pref page is very detailed. Refer to https://github.com/eclipse-platform/eclipse.platform.ui/issues/1002#issuecomment-1787297264. So we can add a setting for ZWSP.
Ah, the whitespace pref page is very detailed. Refer to #1002 (comment). So we can add a setting for ZWSP.
This preference page is located in org.eclipse.ui.editors. See; https://github.com/eclipse-platform/eclipse.platform.ui/blob/44efc1d09a56d4c83a5f529b64aee54a757394f9/bundles/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java#L408
org.eclipse.ui.editors today has a dependency to org.eclipse.ui.workbench.texteditor. I think with this PR we would add a circular dependency when org.eclipse.ui.workbench.texteditor accesses the preference store of org.eclipse.ui.editors.
Wouldn't it be easier to move the org.eclipse.ui.workbench.texteditor.codeMiningProviders extension to the plugin.xml of org.eclipse.ui.editors?