From 0e8c0541befde86fc817771282bd4ad503fe2842 Mon Sep 17 00:00:00 2001 From: oirfeodent Date: Thu, 17 Nov 2016 23:40:40 -0800 Subject: Subsection Folding breaks, when Comment placed between Main & Sub Sections. Bug Fix. --- lexers/LexBaan.cxx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lexers/LexBaan.cxx b/lexers/LexBaan.cxx index 0f5953142..e94195620 100644 --- a/lexers/LexBaan.cxx +++ b/lexers/LexBaan.cxx @@ -258,7 +258,7 @@ static int mainOrSubSectionLine(Sci_Position line, LexAccessor &styler) { } static bool priorSectionIsSubSection(Sci_Position line, LexAccessor &styler){ - while (line != 0) { + while (line > 0) { Sci_Position pos = styler.LineStart(line); Sci_Position eol_pos = styler.LineStart(line + 1) - 1; for (Sci_Position i = pos; i < eol_pos; i++) { @@ -278,6 +278,27 @@ static bool priorSectionIsSubSection(Sci_Position line, LexAccessor &styler){ return false; } +static bool nextSectionIsSubSection(Sci_Position line, LexAccessor &styler) { + while (line > 0) { + Sci_Position pos = styler.LineStart(line); + Sci_Position eol_pos = styler.LineStart(line + 1) - 1; + for (Sci_Position i = pos; i < eol_pos; i++) { + char ch = styler[i]; + int style = styler.StyleAt(i); + if (style == SCE_BAAN_WORD4) + return true; + else if (style == SCE_BAAN_WORD5) + return false; + else if (IsASpaceOrTab(ch)) + continue; + else + break; + } + line++; + } + return false; +} + static bool IsDeclarationLine(Sci_Position line, LexAccessor &styler) { Sci_Position pos = styler.LineStart(line); Sci_Position eol_pos = styler.LineStart(line + 1) - 1; @@ -889,7 +910,9 @@ void SCI_METHOD LexerBaan::Fold(Sci_PositionU startPos, Sci_Position length, int if (!afterFunctionSection) levelCurrent++; } - else if (nextLineStyle != 0 && currLineStyle != nextLineStyle) { + else if (nextLineStyle != 0 && currLineStyle != nextLineStyle + && (priorSectionIsSubSection(lineCurrent -1 ,styler) + || !nextSectionIsSubSection(lineCurrent + 1, styler))) { for (Sci_Position j = styler.LineStart(lineCurrent + 1); j < styler.LineStart(lineCurrent + 1 + 1) - 1; j++) { if (IsASpaceOrTab(styler[j])) continue; -- cgit v1.2.3