1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

Fixed formatting of multi-line string that doesn't start on a new line

This commit is contained in:
Brian Fiete 2025-02-03 10:38:46 -08:00
parent 60fdfff8d7
commit abf58fe89f

View file

@ -1337,6 +1337,8 @@ void BfPrinter::Visit(BfLiteralExpression* literalExpr)
{ {
int srcLineStart = 0; int srcLineStart = 0;
bool startsOnEmptyLine = true;
int checkIdx = literalExpr->GetSrcStart() - 1; int checkIdx = literalExpr->GetSrcStart() - 1;
while (checkIdx >= 0) while (checkIdx >= 0)
{ {
@ -1346,12 +1348,19 @@ void BfPrinter::Visit(BfLiteralExpression* literalExpr)
srcLineStart = checkIdx + 1; srcLineStart = checkIdx + 1;
break; break;
} }
if ((c != '\t') && (c != ' '))
startsOnEmptyLine = false;
checkIdx--; checkIdx--;
} }
int queuedSpaceCount = mQueuedSpaceCount; int queuedSpaceCount = mQueuedSpaceCount;
FlushIndent(); FlushIndent();
if (!startsOnEmptyLine)
{
queuedSpaceCount = mCurIndentLevel * mTabSize;
}
for (int i = literalExpr->GetSrcStart(); i < (int)literalExpr->GetSrcEnd(); i++) for (int i = literalExpr->GetSrcStart(); i < (int)literalExpr->GetSrcEnd(); i++)
{ {
char c = sourceData->mSrc[i]; char c = sourceData->mSrc[i];
@ -1379,6 +1388,9 @@ void BfPrinter::Visit(BfLiteralExpression* literalExpr)
} }
} }
// if (!startsOnEmptyLine)
// mCurIndentLevel--;
return; return;
} }
} }