diff options
author | Neil <nyamatongwe@gmail.com> | 2016-08-30 11:59:01 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2016-08-30 11:59:01 +1000 |
commit | b537f8063c16ad720a03c0347142eaa39310e6a9 (patch) | |
tree | 13d00238e5177a1b47794a1f14b297768fcd4fc1 /lexers/LexCPP.cxx | |
parent | 93876550b9a3c21f4f67253be4ed2c7cb1824c2a (diff) | |
download | scintilla-mirror-b537f8063c16ad720a03c0347142eaa39310e6a9.tar.gz |
Feature [feature-requests:#210]. Allow folding on #else and #elif.
Diffstat (limited to 'lexers/LexCPP.cxx')
-rw-r--r-- | lexers/LexCPP.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index 19b675f59..64387a085 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -320,6 +320,7 @@ struct OptionsCPP { std::string foldExplicitEnd; bool foldExplicitAnywhere; bool foldPreprocessor; + bool foldPreprocessorAtElse; bool foldCompact; bool foldAtElse; OptionsCPP() { @@ -341,6 +342,7 @@ struct OptionsCPP { foldExplicitEnd = ""; foldExplicitAnywhere = false; foldPreprocessor = false; + foldPreprocessorAtElse = false; foldCompact = false; foldAtElse = false; } @@ -411,6 +413,9 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> { DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.cpp.preprocessor.at.else", &OptionsCPP::foldPreprocessorAtElse, + "This option enables folding on a preprocessor #else or #endif line of an #if statement."); DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor, "This option enables folding preprocessor directives when using the C++ lexer. " @@ -1349,13 +1354,17 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int } else if (styler.Match(j, "end")) { levelNext--; } + + if (options.foldPreprocessorAtElse && (styler.Match(j, "else") || styler.Match(j, "elif"))) { + levelMinCurrent--; + } } } if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) { if (ch == '{' || ch == '[' || ch == '(') { // Measure the minimum before a '{' to allow // folding on "} else {" - if (levelMinCurrent > levelNext) { + if (options.foldAtElse && levelMinCurrent > levelNext) { levelMinCurrent = levelNext; } levelNext++; @@ -1367,7 +1376,9 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int visibleChars++; if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; - if (options.foldSyntaxBased && options.foldAtElse) { + if ((options.foldSyntaxBased && options.foldAtElse) || + (options.foldPreprocessor && options.foldPreprocessorAtElse) + ) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; |