aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/LexPython.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2009-07-05 00:28:28 +0000
committernyamatongwe <unknown>2009-07-05 00:28:28 +0000
commitedc269d1d53b02a98435b6da6d935d0c039be69b (patch)
treeef829e98b1c9adaf4f5a14b24e204fd026eeba21 /src/LexPython.cxx
parent90375facb97e9a9c1138b804b8db9edd12199f3c (diff)
downloadscintilla-mirror-edc269d1d53b02a98435b6da6d935d0c039be69b.tar.gz
Python folding uses fold.compact to fix bug #210240 in more cases.
Diffstat (limited to 'src/LexPython.cxx')
-rw-r--r--src/LexPython.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/LexPython.cxx b/src/LexPython.cxx
index 26b96e4db..7d31fd251 100644
--- a/src/LexPython.cxx
+++ b/src/LexPython.cxx
@@ -416,6 +416,8 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
// This option enables folding multi-line quoted strings when using the Python lexer.
const bool foldQuotes = styler.GetPropertyInt("fold.quotes.python") != 0;
+ const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0;
+
// Backtrack to previous non-blank line so we can determine indent level
// for any white space lines (needed esp. within triple quoted strings)
// and so we can fix any preceding fold level (which is why we go back
@@ -514,12 +516,21 @@ static void FoldPyDoc(unsigned int startPos, int length, int /*initStyle - unuse
while (--skipLine > lineCurrent) {
int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
- if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
- skipLevel = levelBeforeComments;
+ if (foldCompact) {
+ if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
+ skipLevel = levelBeforeComments;
+
+ int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
- int whiteFlag = skipLineIndent & SC_FOLDLEVELWHITEFLAG;
+ styler.SetLevel(skipLine, skipLevel | whiteFlag);
+ } else {
+ if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments &&
+ !(skipLineIndent & SC_FOLDLEVELWHITEFLAG) &&
+ !IsCommentLine(skipLine, styler))
+ skipLevel = levelBeforeComments;
- styler.SetLevel(skipLine, skipLevel | whiteFlag);
+ styler.SetLevel(skipLine, skipLevel);
+ }
}
// Set fold header on non-quote/non-comment line