Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistransformation when formatting complex condition with comments #524

Closed
JohnnyMorganz opened this issue Aug 7, 2022 · 0 comments · Fixed by #538
Closed

Mistransformation when formatting complex condition with comments #524

JohnnyMorganz opened this issue Aug 7, 2022 · 0 comments · Fixed by #538
Labels
bug Something isn't working

Comments

@JohnnyMorganz
Copy link
Owner

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant