StyLua
StyLua copied to clipboard
Mistransformation when formatting complex condition with comments
Source: https://github.com/tomrus88/BlizzardInterfaceCode/blob/master/Interface/FrameXML/FlowContainer.lua Source: https://github.com/tomrus88/BlizzardInterfaceCode/blob/master/Interface/FrameXML/SecureGroupHeaders.lua
--If it doesn't fit on the current row, move to the next.
if ( object == "linebreak" or --Force a new line
type(object) == "table" and --Make sure this is an actual object before checking further.
((container.flowMaxPerLine and currentPrimaryLine > container.flowMaxPerLine) or --We went past the max number of columns
currentSecondaryOffset + object["Get"..primaryDirection](object) > container["Get"..primaryDirection](container)) ) then --We went past the max pixel width.
if ( not (atomicAddStart and atomicAtBeginning) ) then --If we're in an atomic add and we started at the beginning of the line, wrapping won't help us
currentSecondaryOffset = 0; --Move back all the way to the left
currentPrimaryLine = 1; --Reset column count
currentPrimaryOffset = currentPrimaryOffset + lineMaxSize + secondarySpacing; --Move down by the size of the biggest object in the last row
currentSecondaryLine = currentSecondaryLine + 1; --Move to the next row.
lineMaxSize = 0;
if ( atomicAddStart ) then
--We wrapped around. So we want to move back to the first item in the atomic add and continue from the position we're leaving off (the new line).
i = atomicAddStart;
atomicAtBeginning = true;
doContinue = true;
end
end
end
if ( name and
((not strictFiltering) and
( tokenTable[subgroup] or tokenTable[className] or (role and tokenTable[role]) or tokenTable[assignedRole] ) -- non-strict filtering
) or
( tokenTable[subgroup] and tokenTable[className] and ((role and tokenTable[role]) or tokenTable[assignedRole]) ) -- strict filtering
) then
tinsert(sortingTable, unit);
sortingTable[unit] = name;
if ( groupBy == "GROUP" ) then
groupingTable[unit] = subgroup;
elseif ( groupBy == "CLASS" ) then
groupingTable[unit] = className;
elseif ( groupBy == "ROLE" ) then
groupingTable[unit] = role;
elseif ( groupBy == "ASSIGNEDROLE" ) then
groupingTable[unit] = assignedRole;
end
end
... gets formatted as ...
--If it doesn't fit on the current row, move to the next.
if
object == "linebreak" --Force a new line
or type(object) == "table" --Make sure this is an actual object before checking further.
and ((container.flowMaxPerLine and currentPrimaryLine > container.flowMaxPerLine) or --We went past the max number of columnscurrentSecondaryOffset + object["Get" .. primaryDirection](
object
) > container["Get" .. primaryDirection](container))
then --We went past the max pixel width.
if not (atomicAddStart and atomicAtBeginning) then --If we're in an atomic add and we started at the beginning of the line, wrapping won't help us
currentSecondaryOffset = 0 --Move back all the way to the left
currentPrimaryLine = 1 --Reset column count
currentPrimaryOffset = currentPrimaryOffset + lineMaxSize + secondarySpacing --Move down by the size of the biggest object in the last row
currentSecondaryLine = currentSecondaryLine + 1 --Move to the next row.
lineMaxSize = 0
if atomicAddStart then
--We wrapped around. So we want to move back to the first item in the atomic add and continue from the position we're leaving off (the new line).
i = atomicAddStart
atomicAtBeginning = true
doContinue = true
end
end
end
if
name
and (not strictFiltering and (tokenTable[subgroup] or tokenTable[className] or (role and tokenTable[role]) or tokenTable[assignedRole]) -- non-strict filtering)
or (tokenTable[subgroup] and tokenTable[className] and ((role and tokenTable[role]) or tokenTable[assignedRole])) -- strict filtering
then
tinsert(sortingTable, unit)
sortingTable[unit] = name
if groupBy == "GROUP" then
groupingTable[unit] = subgroup
elseif groupBy == "CLASS" then
groupingTable[unit] = className
elseif groupBy == "ROLE" then
groupingTable[unit] = role
elseif groupBy == "ASSIGNEDROLE" then
groupingTable[unit] = assignedRole
end
end