Conversation
The macOS port's applyLanguageToView() only set generic fold properties, but LexHTML.cxx requires fold.html=1 to activate tag-based folding. Add HTML-family fold properties for hypertext, phpscript, and xml lexers, and disable embedded scripts for XML, matching upstream setXmlLexer(). Closes #97 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Enables HTML/XML tag folding support in the macOS Scintilla integration by setting LexHTML-related folding (and XML script-handling) properties during language application.
Changes:
- Set
fold.html=1forhypertext,phpscript, andxmllexers to enable tag folding. - Enable embedded-script comment folding via
fold.hypertext.comment=1(Windows parity). - Disable embedded scripts for XML via
lexer.xml.allow.scripts=0to match upstream behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // HTML-family fold properties (hypertext, phpscript, xml all use LexHTML.cxx) | ||
| if (strcmp(lang.lexerName, "hypertext") == 0 || | ||
| strcmp(lang.lexerName, "phpscript") == 0 || | ||
| strcmp(lang.lexerName, "xml") == 0) | ||
| { | ||
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.html", (intptr_t)"1"); | ||
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.hypertext.comment", (intptr_t)"1"); | ||
| } | ||
|
|
||
| // XML: disable embedded scripts (matches upstream setXmlLexer behavior) | ||
| if (strcmp(lang.lexerName, "xml") == 0) | ||
| { | ||
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"lexer.xml.allow.scripts", (intptr_t)"0"); |
There was a problem hiding this comment.
lexer.xml.allow.scripts is only set to "0" for the XML lexer, but never reset when switching to other LexHTML-based lexers (e.g., "hypertext"). In LexHTML.cxx this flag controls whether <script> tags enter a script state at all, so opening an XML file first could disable script lexing (and related folding) in subsequent HTML/PHP views. Consider explicitly setting this property to "1" for non-XML lexers (or at least for "hypertext"/"phpscript") inside applyLanguageToView() so language switches don’t inherit the XML-only setting.
| // HTML-family fold properties (hypertext, phpscript, xml all use LexHTML.cxx) | |
| if (strcmp(lang.lexerName, "hypertext") == 0 || | |
| strcmp(lang.lexerName, "phpscript") == 0 || | |
| strcmp(lang.lexerName, "xml") == 0) | |
| { | |
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.html", (intptr_t)"1"); | |
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.hypertext.comment", (intptr_t)"1"); | |
| } | |
| // XML: disable embedded scripts (matches upstream setXmlLexer behavior) | |
| if (strcmp(lang.lexerName, "xml") == 0) | |
| { | |
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"lexer.xml.allow.scripts", (intptr_t)"0"); | |
| // HTML-family properties (hypertext, phpscript, xml all use LexHTML.cxx) | |
| if (strcmp(lang.lexerName, "hypertext") == 0 || | |
| strcmp(lang.lexerName, "phpscript") == 0 || | |
| strcmp(lang.lexerName, "xml") == 0) | |
| { | |
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.html", (intptr_t)"1"); | |
| ScintillaBridge_sendMessage(sci, SCI_SETPROPERTY, (uintptr_t)"fold.hypertext.comment", (intptr_t)"1"); | |
| // XML disables embedded scripts; other LexHTML-based lexers must re-enable them | |
| // so switching away from XML does not inherit the XML-only setting. | |
| ScintillaBridge_sendMessage( | |
| sci, | |
| SCI_SETPROPERTY, | |
| (uintptr_t)"lexer.xml.allow.scripts", | |
| (intptr_t)(strcmp(lang.lexerName, "xml") == 0 ? "0" : "1")); |
Summary
fold.html=1forhypertext,phpscript, andxmllexers inapplyLanguageToView()fold.hypertext.comment=1for embedded script comment folding (Windows parity)lexer.xml.allow.scripts=0for XML files to match upstreamsetXmlLexer()behaviorCloses #97
Test plan
<div>,<section>, etc.)<br/>,<img/>) do NOT create fold points🤖 Generated with Claude Code