From 6e71cbc765f9857bb06d9dc67f9fb2a3048d0ed9 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 22 Oct 2020 07:05:11 -0700 Subject: [PATCH] Fixed indenting for op-assignment operator overloads --- IDE/src/ui/SourceEditWidgetContent.bf | 29 ++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index 5ec8ef17..de7244c1 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -1904,6 +1904,7 @@ namespace IDE.ui if (indentCount == column / 4) { bool isExpr = false; + bool mayBeExpr = false; char8 prevC = 0; int checkIdx = CursorTextPos - 1; @@ -1918,7 +1919,29 @@ namespace IDE.ui continue; } 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 == ')') { parenOpenCount++; @@ -1940,8 +1963,8 @@ namespace IDE.ui break; if (prevC == '=') { - isExpr = true; - break; + // Is expression if this isn't following the word 'operator' + mayBeExpr = true; } }