1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Improved #region collapse behavior

This commit is contained in:
Brian Fiete 2022-03-02 12:10:16 -08:00
parent 5fc95f8f07
commit 6fe9c97649
3 changed files with 45 additions and 17 deletions

View file

@ -9201,8 +9201,21 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
mStartSeriesIdx = -1;
}
int GetLineStartAfter(int startIdx)
{
for (int i = startIdx; i < mParser->mSrcLength - 1; i++)
{
if (mParser->mSrc[i] == '\n')
return i + 1;
}
return -1;
}
void Add(int anchor, int start, int end, char kind = '?')
{
if ((anchor == -1) || (start == -1) || (end == -1))
return;
bool isMultiline = false;
for (int i = start; i < end; i++)
{
@ -9396,7 +9409,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
regionStart = preprocessorNode->mCommand;
else if (sv == "endregion")
{
collapseVisitor.Add(regionStart, regionStart, preprocessorNode->mCommand, 'R');
if (regionStart != NULL)
collapseVisitor.Add(regionStart->mSrcStart, collapseVisitor.GetLineStartAfter(regionStart->mSrcStart), preprocessorNode->mCommand->mSrcStart, 'R');
regionStart = NULL;
}