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