Community
Participate
Working Groups
On Windows, StyledText#addBidiSegmentListener(..) only works if an RTL input language is installed in the OS. This limitation is not documented there, and it is unexpected. Javadocs of BidiSegmentEvent and BidiSegmentListener#lineGetSegments(BidiSegmentEvent) mention "in a bidi locale", but that is not the correct precondition, and is easy to miss (especially on non-Windows platforms, where bidi-processing is always enabled, see StyledText#isBidi()). Furthermore, org.eclipse.swt.internal.BidiUtil.isBidiPlatform() caches the value, so changes in the OS are not reflected until the application is restarted. This hits us in bug 400662 (and in debug's ProcessPropertyPage). I think the best solution is to remove StyledText#isBidi() and always process BidiSegmentListeners. Eclipse workbench plug-ins that want to reduce bidi-processing overhead should rely on the new command line flag proposed in bug 383185: -bidi "on=[y/n];textDir=[ltr/rtl/auto]"
Created attachment 228136 [details] Fix Can we fix this for M6? I can release the fix unless there's opposition.
My only concern is whether this will case performance degradation on Windows. Do you have any numbers? The command line switch will only help eclipse plugins. I am not a big fun of system properties, but we could add this line to the beginning of isBidi(): if (!"true".equals(System.getProperty("org.eclipse.swt.checkBidiLocale"))) return true;
It will cause more BidiSegmentListener callbacks, but it can't be a relevant performance degradation, since we already accept this unconditionally on Mac and GTK, and on Windows platforms where a bidi keyboard language is installed. In the Eclipse SDK, the only relevant BidiSegmentListener is in the JavaSourceViewer. This is called every time a line is rendered in a Java editor. When I scroll 1000 lines of StyledText (takes about 30s here), both YourKit and System.currentTimeMillis() have a hard time measuring any time spent in StyledText#getBidiSegments(..). Often, it's 0ms, sometimes 1ms. Accumulated over the 30s, it's around 30ms. I think we should just remove this and we don't need a system property.
OK, +1 to your patch.
Thanks, fixed in master: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=629abafba5977a03a6e3729c999fb7b78b57e631