diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | lexers/LexHTML.cxx | 27 | 
2 files changed, 28 insertions, 3 deletions
| diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index c9d5da260..6f823d593 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -573,6 +573,10 @@  	SciTE enables use of SCI_ commands in user.context.menu.  	</li>   	<li> +	XML folder adds fold.xml.at.tag.open option to fold tags at the start of the tag "<" instead of the end ">". +	<a href="https://sourceforge.net/p/scintilla/bugs/2128/">Bug #2128</a>. +	</li> + 	<li>  	Metapost lexer fixes crash with 'interface=none' comment.  	<a href="https://sourceforge.net/p/scintilla/bugs/2129/">Bug #2129</a>.  	</li> diff --git a/lexers/LexHTML.cxx b/lexers/LexHTML.cxx index 96462235f..9d9ec9bb1 100644 --- a/lexers/LexHTML.cxx +++ b/lexers/LexHTML.cxx @@ -562,6 +562,7 @@ struct OptionsHTML {  	bool foldCompact = true;  	bool foldComment = false;  	bool foldHeredoc = false; +	bool foldXmlAtTagOpen = false;  	OptionsHTML() noexcept {  	}  }; @@ -626,6 +627,10 @@ struct OptionSetHTML : public OptionSet<OptionsHTML> {  			"Allow folding for heredocs in scripts embedded in HTML. "  			"The default is off."); +		DefineProperty("fold.xml.at.tag.open", &OptionsHTML::foldXmlAtTagOpen, +			"Enable folding for XML at the start of open tag. " +			"The default is off."); +  		DefineWordListSets(isPHPScript_ ? phpscriptWordListDesc : htmlWordListDesc);  	}  }; @@ -991,6 +996,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  	const bool foldCompact = options.foldCompact;  	const bool foldComment = fold && options.foldComment;  	const bool foldHeredoc = fold && options.foldHeredoc; +	const bool foldXmlAtTagOpen = isXml && fold && options.foldXmlAtTagOpen;  	const bool caseSensitive = options.caseSensitive;  	const bool allowScripts = options.allowScripts;  	const bool isMako = options.isMako; @@ -1206,6 +1212,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  				i += 2;  				visibleChars += 2;  				tagClosing = true; +				if (foldXmlAtTagOpen) { +					levelCurrent--; +				}  				continue;  			}  		} @@ -1531,6 +1540,12 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  				// in HTML, fold on tag open and unfold on tag close  				tagOpened = true;  				tagClosing = (chNext == '/'); +				if (foldXmlAtTagOpen && !(chNext == '/' || chNext == '?' || chNext == '!' || chNext == '-' || chNext == '%')) { +					levelCurrent++; +				} +				if (foldXmlAtTagOpen && chNext == '/') { +					levelCurrent--; +				}  				styler.ColourTo(i - 1, StateToPrint);  				if (chNext != '!')  					state = SCE_H_TAGUNKNOWN; @@ -1727,7 +1742,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  						state = SCE_H_DEFAULT;  					}  					tagOpened = false; -					if (!tagDontFold) { +					if (!(foldXmlAtTagOpen || tagDontFold)) {  						if (tagClosing) {  							levelCurrent--;  						} else { @@ -1746,6 +1761,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  					ch = chNext;  					state = SCE_H_DEFAULT;  					tagOpened = false; +					if (foldXmlAtTagOpen) { +						levelCurrent--; +					}  				} else {  					if (eClass != SCE_H_TAGUNKNOWN) {  						if (eClass == SCE_H_SGML_DEFAULT) { @@ -1775,7 +1793,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  						state = SCE_H_DEFAULT;  					}  					tagOpened = false; -					if (!tagDontFold) { +					if (!(foldXmlAtTagOpen || tagDontFold)) {  						if (tagClosing) {  							levelCurrent--;  						} else { @@ -1801,7 +1819,7 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  					state = SCE_H_DEFAULT;  				}  				tagOpened = false; -				if (!tagDontFold) { +				if (!(foldXmlAtTagOpen || tagDontFold)) {  					if (tagClosing) {  						levelCurrent--;  					} else { @@ -1825,6 +1843,9 @@ void SCI_METHOD LexerHTML::Lex(Sci_PositionU startPos, Sci_Position length, int  				ch = chNext;  				state = SCE_H_DEFAULT;  				tagOpened = false; +				if (foldXmlAtTagOpen) { +					levelCurrent--; +				}  			} else if (ch == '?' && chNext == '>') {  				styler.ColourTo(i - 1, StateToPrint);  				styler.ColourTo(i + 1, SCE_H_XMLEND); | 
