Folding sometimes not available

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
awagner
Posts: 4
Joined: Thu May 15, 2014 1:51 pm

Folding sometimes not available

Post by awagner » Wed Oct 21, 2020 4:54 pm

Dear all,

why would there be occasions when oxygen seems not to recognize where it could fold my code?

I have a long xslt stylesheet where no folding triangle buttons are available in the gutter. When I delete everything except the following, it still does not work:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tei="http://www.tei-c.org/ns/1.0"
    xmlns="http://www.tei-c.org/ns/1.0"
    exclude-result-prefixes="xs"
    version="2.0">

    <xsl:variable name="identifiedAbbr">
        <xsl:apply-templates select="/" mode="identify-abbr"/>
        <xsl:message select="'INFO: identified abbreviations.'"/>
    </xsl:variable>

    <!-- identity transform -->
    <xsl:template match="@*|node()" mode="identify-abbr">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" mode="identify-abbr"/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>
When I add this same code to a new document, it is possible to fold. But I am reluctant to post the full stylesheet. There must be something in it tripping up oxygen's folding logic...

The code seems well-formed, the lines in the gutter indicating the extent of the currently focused element are working, and in oxygen for linux, the very same code can be folded. In oxygen for windows, however, it cannot. I have folding enabled in the settings and in fact, in the next tab, there is an xml file that folds nicely...

So I guess my question is: What factors can influence folding?

Best,
Andreas

adrian
Posts: 2727
Joined: Tue May 17, 2005 4:01 pm

Re: Folding sometimes not available

Post by adrian » Mon Oct 26, 2020 2:03 pm

Hello,

What version and build of Oxygen are you using (Help > About)?
awagner wrote:
Wed Oct 21, 2020 4:54 pm
So I guess my question is: What factors can influence folding?
If the syntax highlight breaks, folding can sometimes also fail. So, if you see tags, attributes, or text colored in red (or otherwise having the incorrect color for the respective XML token), the syntax highlight has failed. If that's the case, it should also provide some clue of what piece of code is making it fail as that portion should be incorrectly highlighted.

Folding can also be disabled completely for documents requiring Special Character Support. It's less likely to encounter this for an XSLT document, but you may have a stray Unicode character that triggers this. Look in the Properties view (Window > Show view > ...) for the BIDI property. If it's set to true, that is the cause.
To control this, go to Options > Preferences, Editor > Open and set "Support for Special Characters" to "Prompt for each document", close and reopen your document. Pick Disable when asked about the support for special characters.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

awagner
Posts: 4
Joined: Thu May 15, 2014 1:51 pm

Re: Folding sometimes not available

Post by awagner » Tue Oct 27, 2020 6:01 pm

adrian wrote:
Mon Oct 26, 2020 2:03 pm
you may have a stray Unicode character that triggers this. Look in the Properties view (Window > Show view > ...) for the BIDI property. If it's set to true, that is the cause.
To control this, go to Options > Preferences, Editor > Open and set "Support for Special Characters" to "Prompt for each document", close and reopen your document. Pick Disable when asked about the support for special characters.
Seems that is the culprit: The BIDI property is true on both platforms, but on my linux box I had support disabled already and on windows I did not (yet). Now I have disabled support for special characters also on windows and that fixed it.

Thank you!!

Best,
Andreas

For completeness' sake:
adrian wrote:
Mon Oct 26, 2020 2:03 pm
What version and build of Oxygen are you using (Help > About)?
On windows it's XML Editor 22.1, build 2020100710, on linux it's XML Editor 22.0 build 2020030607

wujastyk
Posts: 1
Joined: Tue Apr 27, 2021 4:27 am

Re: Folding sometimes not available

Post by wujastyk » Tue Apr 27, 2021 4:36 am

BIDI and special character support are two different things. I have no BIDI files and BIDI is never set. But I do have some files with Devanagari in them (many ligatures) and also files in Latin script with many extra diacritical marks (śāstri, Kṛṣṇa, etc.). It what follows, I'm only talking about Latin script files.

And others that do show folding when special chars is off, and don't when it's on (as described in earlier messages).

But I also have files that always open with folding enabled, whether or not they are opened with special chars enabled or not.

So something else is going on in addition to the points mentioned earlier in this thread.

When oXygen's menus refer to "Asian languages or other special characters" what do they mean, exactly? Are Asian languages in Latin transliteration included in Asian languages? Which special characters?

Many thanks,
Dominik Wuajstyk

adrian
Posts: 2727
Joined: Tue May 17, 2005 4:01 pm

Re: Folding sometimes not available

Post by adrian » Thu May 06, 2021 4:04 pm

Hello,
BIDI and special character support are two different things.
They may mean different things, but technically they refer to the same support in Oxygen. The BIDI property has remained named as such because it was initially named "BiDi support". However, note that the BIDI property may be set to "true", but the support can still be disabled. The BIDI property indicates that there is a character in the text that causes this support to be triggered, so even if you chose to disable the support (or it was forcefully disabled) the BIDI property will still indicate "true".

Basically Java calls this "Bidirectional text support" ("BiDi support" for short), but since it can also be triggered and is needed for combining characters and some special glyphs with ligatures, we chose to rename it to "Support for Special Characters" in the GUI messages. The naming was chosen because there can be no BiDi (or RTL) text but the support is still triggered. While this "Special Characters" naming is rather vague, it covers several situations, not just Bidirectional text. The special characters popup message (the one that prompts you to enable or disable this support) tries to explain the situation and type of text that triggers this.

Regarding folding support, the documentation clearly mentions that:
When support for special characters is enabled, the folding support is not available.
But I also have files that always open with folding enabled, whether or not they are opened with special chars enabled or not.
I'm not saying it's impossible, maybe you've found a bug that lets the folding support enabled with special characters in some situation. But, by design, if special characters support is indeed enabled, then folding gets disabled on purpose.
Note that even the special characters mode can be forcefully disabled when some limits are exceeded (e.g. size > 300k) due to performance reasons. This is also controlled from the Options > Preferences, Editor > Open. If the support is forcefully disabled then folding becomes active.
What I'm saying is that you might believe that special characters supports is enabled, when in reality it's not due to this size limitation. This is a more plausible reason for the folding support being enabled.
When oXygen's menus refer to "Asian languages or other special characters" what do they mean, exactly? Are Asian languages in Latin transliteration included in Asian languages? Which special characters?
As mentioned above, "Support for Special Characters" refers to special combining characters and some glyphs with ligatures that are used in South/South-East Asian text (this is in addition to RTL text).
I can't provide an exact list of languages or a table of characters that trigger this. This support (for text mode) is implemented by the underlying Java framework, so if you change the version of Java, it may also slightly change.
Asian languages in Latin transliteration are unlikely to trigger this support, but if you have a single combining character that slipped by in the text, it will be triggered (check the BIDI property).

If you believe there shouldn't be any character in the content that triggers this, a good start is searching for "Combining characters" (Unicode range 0300–036F). Use Find/Replace with "Regular expression" enabled and "[\u0300-\u036f]" (without the quotes). Combining characters are the most encountered and elusive type of characters that trigger the special characters support.

If you can't find anything in the range of "Combining characters" and you know that there shouldn't be any "special characters" in the file, but suspect a random mistake in the text, try the entire Unicode non-ASCII range "[\u0100-\uffff]". Note that very few characters from this range actually trigger BiDi, but it should at least provide a clue if something accidentally slipped by in the Latin text.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Post Reply