1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed indentation when prior line ends with comment

This commit is contained in:
Brian Fiete 2022-05-26 16:01:55 -07:00
parent 866bddde2e
commit d881337a7e

View file

@ -756,14 +756,15 @@ void BfPrinter::Visit(BfAstNode* bfAstNode)
{
SetAndRestoreValue<bool> prevForceTrivia(mForceUseTrivia);
bool expectingNewLine = mNextStateModify.mWantNewLineIdx != mVirtualNewLineIdx;
if (expectingNewLine)
bool newExpectingNewLine = mNextStateModify.mWantNewLineIdx != mVirtualNewLineIdx;
if (newExpectingNewLine)
mExpectingNewLine = true;
bool expectingNewLine = mExpectingNewLine;
int indentOffset = 0;
if (bfAstNode->GetTriviaStart() != -1)
{
if (expectingNewLine)
if (newExpectingNewLine)
{
indentOffset = mNextStateModify.mWantVirtualIndent - mVirtualIndentLevel;
mVirtualIndentLevel += indentOffset;
@ -884,7 +885,7 @@ void BfPrinter::Visit(BfAstNode* bfAstNode)
mQueuedSpaceCount = mCurIndentLevel * mTabSize;
// Indents extra if we have a statement split over multiple lines
if (!mExpectingNewLine)
if (!expectingNewLine)
mQueuedSpaceCount += mTabSize;
break;
@ -944,7 +945,7 @@ void BfPrinter::Visit(BfAstNode* bfAstNode)
idx--;
}
}
else if ((mNextStateModify.mExpectingSpace) || (expectingNewLine))
else if ((mNextStateModify.mExpectingSpace) || (newExpectingNewLine))
{
FlushIndent();
char startChar = bfAstNode->GetSourceData()->mSrc[bfAstNode->GetSrcStart()];