From 85acdda2b467eec7048f1451556e8ab5ba3b777e Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 2 Mar 2022 17:26:44 -0800 Subject: [PATCH] Fixed invalid collapse comment batching --- IDEHelper/Compiler/BfCompiler.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index ef3d6658..f1f0d11e 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/IDEHelper/Compiler/BfCompiler.cpp @@ -9212,12 +9212,21 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo } int anchor = mStartSeriesIdx; + if (!ownsLine) { - int nextLine = GetLineStartAfter(anchor); - if (nextLine != -1) - anchor = nextLine; + int checkLine = GetLineStartAfter(anchor); + if (checkLine != -1) + { + anchor = checkLine; + for (; anchor < mEndSeriesIdx; anchor++) + { + if (!::isspace((uint8)mParser->mSrc[anchor])) + break; + } + } } + Add(anchor, mEndSeriesIdx, mSeriesKind); } mStartSeriesIdx = -1; @@ -9227,8 +9236,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo { for (int i = startIdx; i < mParser->mSrcLength - 1; i++) { - if (mParser->mSrc[i] == '\n') - return i + 1; + if (mParser->mSrc[i] == '\n') + return i + 1; } return -1; }