1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-12 05:14:10 +02:00

Fixed indenting for op-assignment operator overloads

This commit is contained in:
Brian Fiete 2020-10-22 07:05:11 -07:00
parent 9b5324d343
commit 6e71cbc765

View file

@ -1904,6 +1904,7 @@ namespace IDE.ui
if (indentCount == column / 4) if (indentCount == column / 4)
{ {
bool isExpr = false; bool isExpr = false;
bool mayBeExpr = false;
char8 prevC = 0; char8 prevC = 0;
int checkIdx = CursorTextPos - 1; int checkIdx = CursorTextPos - 1;
@ -1918,7 +1919,29 @@ namespace IDE.ui
continue; continue;
} }
prevC = mData.mText[checkIdx].mChar; prevC = mData.mText[checkIdx].mChar;
if (mayBeExpr)
{
if (prevC.IsWhiteSpace)
continue;
if ((prevC == '(') || (prevC == ')') || (prevC == '{') || (prevC == '}'))
{
mayBeExpr = false;
}
else if (prevC.IsLetterOrDigit)
{
if ((prevC == 'r') && (displayType == .Keyword))
{
// operator overload
mayBeExpr = false;
continue;
}
isExpr = true;
break;
}
}
if (prevC == ')') if (prevC == ')')
{ {
parenOpenCount++; parenOpenCount++;
@ -1940,8 +1963,8 @@ namespace IDE.ui
break; break;
if (prevC == '=') if (prevC == '=')
{ {
isExpr = true; // Is expression if this isn't following the word 'operator'
break; mayBeExpr = true;
} }
} }