mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 22:34:09 +02:00
Fixed indentation detection
This commit is contained in:
parent
41858b3dc5
commit
3bb2e8947f
1 changed files with 36 additions and 2 deletions
|
@ -1891,20 +1891,54 @@ namespace IDE.ui
|
||||||
// If we're aligned with the previous line then do the 'block indent' logic, otherwise are are already indented
|
// If we're aligned with the previous line then do the 'block indent' logic, otherwise are are already indented
|
||||||
if (indentCount == column / 4)
|
if (indentCount == column / 4)
|
||||||
{
|
{
|
||||||
|
bool isLambdaOpen = false;
|
||||||
|
bool isExpr = false;
|
||||||
|
|
||||||
char8 prevC = 0;
|
char8 prevC = 0;
|
||||||
int checkIdx = CursorTextPos - 1;
|
int checkIdx = CursorTextPos - 1;
|
||||||
|
int parenOpenCount = 0;
|
||||||
|
|
||||||
while (checkIdx >= 0)
|
while (checkIdx >= 0)
|
||||||
{
|
{
|
||||||
let displayType = (SourceElementType)mData.mText[checkIdx].mDisplayTypeId;
|
let displayType = (SourceElementType)mData.mText[checkIdx].mDisplayTypeId;
|
||||||
if (displayType == .Comment)
|
if (displayType == .Comment)
|
||||||
continue;
|
continue;
|
||||||
prevC = mData.mText[checkIdx].mChar;
|
prevC = mData.mText[checkIdx].mChar;
|
||||||
if (!prevC.IsWhiteSpace)
|
if (prevC == '>')
|
||||||
|
{
|
||||||
|
isLambdaOpen = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
if (prevC == ')')
|
||||||
|
{
|
||||||
|
parenOpenCount++;
|
||||||
|
}
|
||||||
|
if (prevC == '(')
|
||||||
|
{
|
||||||
|
parenOpenCount--;
|
||||||
|
if (parenOpenCount < 0)
|
||||||
|
{
|
||||||
|
isExpr = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (prevC == '{')
|
||||||
|
break;
|
||||||
|
if (parenOpenCount == 0)
|
||||||
|
{
|
||||||
|
if (prevC == ';')
|
||||||
|
break;
|
||||||
|
if (prevC == '=')
|
||||||
|
{
|
||||||
|
isLambdaOpen = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkIdx--;
|
checkIdx--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prevC == '>') || (prevC == ')'))
|
if ((isLambdaOpen) || (isExpr))
|
||||||
{
|
{
|
||||||
// Lambda opening or initializer expression
|
// Lambda opening or initializer expression
|
||||||
column += 4;
|
column += 4;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue