diff options
author | Neil <nyamatongwe@gmail.com> | 2017-04-21 12:49:02 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2017-04-21 12:49:02 +1000 |
commit | 596e7f91811d9d39853051e0dee691e490ce95e0 (patch) | |
tree | 2f1def62402346750eb191a23fba95e2e9ab4db6 | |
parent | 261277783fa16e0c974b1981a5eb0a208fca955e (diff) | |
download | scintilla-mirror-596e7f91811d9d39853051e0dee691e490ce95e0.tar.gz |
Treat comments at the end of the file as separate from the preceding structure.
-rw-r--r-- | doc/ScintillaHistory.html | 3 | ||||
-rw-r--r-- | lexers/LexPython.cxx | 10 |
2 files changed, 11 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 6001a4802..d504bb6d3 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -552,6 +552,9 @@ The Python lexer recognizes identifiers more accurately when they include non-ASCII characters. </li> <li> + The Python folder treats comments at the end of the file as separate from the preceding structure. + </li> + <li> The YAML lexer recognizes comments in more situations and styles a "..." line like a "---" line. <a href="http://sourceforge.net/p/scintilla/bugs/1931/">Bug #1931</a>. diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx index 328ed7363..97943ca24 100644 --- a/lexers/LexPython.cxx +++ b/lexers/LexPython.cxx @@ -887,18 +887,24 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i // Skip past any blank lines for next indent level info; we skip also // comments (all comments, not just those starting in column 0) // which effectively folds them into surrounding code rather - // than screwing up folding. + // than screwing up folding. If comments end file, use the min + // comment indent as the level after + int minCommentLevel = indentCurrentLevel; while (!quote && (lineNext < docLines) && ((indentNext & SC_FOLDLEVELWHITEFLAG) || (lineNext <= docLines && IsCommentLine(lineNext, styler)))) { + if (IsCommentLine(lineNext, styler) && indentNext < minCommentLevel) { + minCommentLevel = indentNext; + } + lineNext++; indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); } - const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK; + const int levelAfterComments = ((lineNext < docLines) ? indentNext & SC_FOLDLEVELNUMBERMASK : minCommentLevel); const int levelBeforeComments = Maximum(indentCurrentLevel, levelAfterComments); // Now set all the indent levels on the lines we skipped |