mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 14:01:37 +00:00
Enhance property handling in PatchTree.build function to support EnumItem conversion for incoming raw numbers. Improved readability by restructuring property change checks and maintaining line change calculations for Source properties.
This commit is contained in:
parent
196cf7aed7
commit
06457bc0db
1 changed files with 31 additions and 14 deletions
|
|
@ -256,24 +256,41 @@ function PatchTree.build(patch, instanceMap, changeListHeaders)
|
|||
addProp("Name", instance.Name, change.changedName)
|
||||
end
|
||||
|
||||
for prop, incoming in change.changedProperties do
|
||||
local incomingSuccess, incomingValue = decodeValue(incoming, instanceMap)
|
||||
local currentSuccess, currentValue = getProperty(instance, prop)
|
||||
for prop, incoming in change.changedProperties do
|
||||
local incomingSuccess, incomingValue = decodeValue(incoming, instanceMap)
|
||||
local currentSuccess, currentValue = getProperty(instance, prop)
|
||||
|
||||
-- Check if this is a Source property - count line differences
|
||||
if prop == "Source" and currentSuccess and incomingSuccess then
|
||||
hasSourceChange = true
|
||||
totalLineChanges, whitespaceLineChanges =
|
||||
WhitespaceUtil.CountLineDifferences(currentValue, incomingValue)
|
||||
-- If incoming is a raw number and current is an EnumItem, convert incoming
|
||||
-- to the proper EnumItem for better display (server sends Enum as raw numbers)
|
||||
if
|
||||
incomingSuccess
|
||||
and currentSuccess
|
||||
and typeof(incomingValue) == "number"
|
||||
and typeof(currentValue) == "EnumItem"
|
||||
then
|
||||
local enumType = currentValue.EnumType
|
||||
local ok, converted = pcall(function()
|
||||
return enumType:FromValue(incomingValue)
|
||||
end)
|
||||
if ok and converted then
|
||||
incomingValue = converted
|
||||
end
|
||||
|
||||
addProp(
|
||||
prop,
|
||||
if currentSuccess then currentValue else "[Error]",
|
||||
if incomingSuccess then incomingValue else select(2, next(incoming))
|
||||
)
|
||||
end
|
||||
|
||||
-- Check if this is a Source property - count line differences
|
||||
if prop == "Source" and currentSuccess and incomingSuccess then
|
||||
hasSourceChange = true
|
||||
totalLineChanges, whitespaceLineChanges =
|
||||
WhitespaceUtil.CountLineDifferences(currentValue, incomingValue)
|
||||
end
|
||||
|
||||
addProp(
|
||||
prop,
|
||||
if currentSuccess then currentValue else "[Error]",
|
||||
if incomingSuccess then incomingValue else select(2, next(incoming))
|
||||
)
|
||||
end
|
||||
|
||||
-- Count non-Source property changes
|
||||
local propCount = changeIndex - (if hasSourceChange then 1 else 0)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue