From edc269d1d53b02a98435b6da6d935d0c039be69b Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sun, 5 Jul 2009 00:28:28 +0000 Subject: Python folding uses fold.compact to fix bug #210240 in more cases. --- src/LexPython.cxx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/LexPython.cxx') 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 -- cgit v1.2.3