Skip to content

Commit

Permalink
Show failed additions and removals in visualizer (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
boatbomber authored Jan 31, 2024
1 parent 506a60d commit 106a012
Showing 1 changed file with 58 additions and 14 deletions.
72 changes: 58 additions & 14 deletions plugin/src/PatchTree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -426,22 +426,66 @@ function PatchTree.updateMetadata(tree, patch, instanceMap, unappliedPatch)
-- Update isWarning metadata
for _, failedChange in unappliedPatch.updated do
local node = tree:getNode(failedChange.id)
if node then
node.isWarning = true
Log.trace("Marked node as warning: {} {}", node.id, node.name)

if node.changeList then
for _, change in node.changeList do
if failedChange.changedProperties[change[1]] then
Log.trace(" Marked property as warning: {}", change[1])
if change[4] == nil then
change[4] = {}
end
change[4].isWarning = true
end
end
if not node then
continue
end

node.isWarning = true
Log.trace("Marked node as warning: {} {}", node.id, node.name)

if not node.changeList then
continue
end
for _, change in node.changeList do
if not failedChange.changedProperties[change[1]] then
-- This change didn't fail
continue
end
if change[4] == nil then
change[4] = { isWarning = true }
else
change[4].isWarning = true
end
Log.trace(" Marked property as warning: {}.{}", node.name, change[1])
end
end
for failedAdditionId in unappliedPatch.added do
local node = tree:getNode(failedAdditionId)
if not node then
continue
end

node.isWarning = true
Log.trace("Marked node as warning: {} {}", node.id, node.name)

if not node.changeList then
continue
end
for _, change in node.changeList do
-- Failed addition means that all properties failed to be added
if change[4] == nil then
change[4] = { isWarning = true }
else
change[4].isWarning = true
end
Log.trace(" Marked property as warning: {}.{}", node.name, change[1])
end
end
for _, failedRemovalIdOrInstance in unappliedPatch.removed do
local failedRemovalId = if Types.RbxId(failedRemovalIdOrInstance)
then failedRemovalIdOrInstance
else instanceMap.fromInstances[failedRemovalIdOrInstance]
if not failedRemovalId then
continue
end

local node = tree:getNode(failedRemovalId)
if not node then
continue
end

node.isWarning = true
Log.trace("Marked node as warning: {} {}", node.id, node.name)
end

-- Update if instances exist
Expand Down

0 comments on commit 106a012

Please sign in to comment.