diff options
author | Zufu Liu <unknown> | 2017-08-07 09:07:38 +1000 |
---|---|---|
committer | Zufu Liu <unknown> | 2017-08-07 09:07:38 +1000 |
commit | 3c8b4da72943aec8aa894c0cdf430ae7bb06162f (patch) | |
tree | 617c430525c7623639bdc2e9bbaa7aa463e8f8c4 | |
parent | 067151f66d792599e35aa7964ade16df0802abae (diff) | |
download | scintilla-mirror-3c8b4da72943aec8aa894c0cdf430ae7bb06162f.tar.gz |
Backport: Bug [#1965]. Implement "fold", "fold.comment", and "fold.compact" properties.
Backport of changeset 6365:c18a8402702f.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexMatlab.cxx | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 4b8cc6dd2..f0b817ba0 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -548,6 +548,10 @@ <a href="http://sourceforge.net/p/scintilla/bugs/1951/">Bug #1951</a>. </li> <li> + The Matlab folder implements "fold", "fold.comment", and "fold.compact" properties. + <a href="http://sourceforge.net/p/scintilla/bugs/1965/">Bug #1965</a>. + </li> + <li> The Rust lexer recognizes 'usize' numeric literal suffixes. <a href="http://sourceforge.net/p/scintilla/bugs/1919/">Bug #1919</a>. </li> diff --git a/lexers/LexMatlab.cxx b/lexers/LexMatlab.cxx index a0e3ea937..154c755fd 100644 --- a/lexers/LexMatlab.cxx +++ b/lexers/LexMatlab.cxx @@ -294,6 +294,12 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int WordList *[], Accessor &styler, bool (*IsComment)(int ch)) { + if (styler.GetPropertyInt("fold") == 0) + return; + + const bool foldComment = styler.GetPropertyInt("fold.comment") != 0; + const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + Sci_PositionU endPos = startPos + length; int visibleChars = 0; Sci_Position lineCurrent = styler.GetLine(startPos); @@ -314,7 +320,7 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); // a line that starts with a comment - if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) { + if (foldComment && style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) { // start/end of block comment if (chNext == '{' && IsSpaceToEOL(i+2, styler)) levelNext ++; @@ -340,7 +346,7 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; int lev = levelUse | levelNext << 16; - if (visibleChars == 0) + if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; |