Attached patch (+ full file) adds support for folding:
* PHP multi-line comments (ref: #2130579)
* PHP HEREDOC/NOWDOC strings (ref: #1945003)
* Javascript multi-line comments
I'm not sure it's a good idea to modify levelCurrent after the folding code near the beginning of the colourise loop (which only triggers on line breaks). But in my tests, the patch has not caused any problems.
Patch v1
The C++ lexer has a fold.comment setting. Are you sure that every PHP/Javascript user is going to want their heredocs and comments to fold?
Not at all certain, but I have considered making it optional.
Patch v2
Patch v2 uses the "global" fold.comment pref, like the C++ lexer, and adds a new fold.heredoc pref, which other lexers (Bash, Perl...?) can use, too. Both prefs default to off.
File Added: php_js_folding.zip
A couple of years back I defined a convention for new fold/lexer properties so that they could be automatically found by scripts. The convention should be in the documentation but looks like it was only ever posted on the mailing list. To match, these should be called something like fold.hypertext.comment and fold.hypertext.heredoc since the lexer name is 'hypertext'.
Unfortunately, I cannot find any reference to the property naming conventions. Could you point me to the mailing list post which explains? Or if no archive exists online, forward it to the current Scintilla-Interest group, where I am already subscribed.
Thanks!
http://www.mail-archive.com/scintilla-interest@lyra.org/msg00667.html
Just added a shorter version to ScintillaDoc.html in CVS.
Patch v3
Thanks. I take it you don't want the HTML lexer re-using the fold.comment property that the C++ lexer already uses. In that case, fold.hypertext.comment and fold.hypertext.heredoc work fine. Updated patch with new pref names. (trivial)
File Added: LexHTML.cxx.patch
OK, I'm happy with that. I wasn't sure whether that was the best naming or whether it should be more specific like lexer.hypertext.php.heredoc. People often want more control over the hypertext lexer and its more likely to be used in conjunction with another language. For example, having C++ and Pascal share a variable may not be a problem since they are less likely to be used in a single project but its common to have Java and HTML in a single project and a user may want different options for the two languages.
That's a good point; comment folding in the patch applies to both JS and PHP, and heredoc folding only to PHP. I can't state for certain that any of the other languages in the HTML lexer don't have heredoc syntax, but it would surprise me if they did. To be quite honest, the pref names do not matter to me ... as long as I can set them, anything will work.
Committed.
Released in 1.78.