This is a long-standing problem in driver.love as well:
Solution: create a variant of A called A1 that only does the work of A for a single node id (index) into Nodes.
This requires tracking for every shape we render in Surface, which id it is part of. That way we can selectively delete just shapes belonging to a single id.
Caveat: id is a scalar, so this approach can't handle any nesting, only a flat array of objects. But that's good enough for both driver.love and this app.
3L7AIL636NDE5BOTG3LXW44CFW7H2QFBH3LGMSF6NYHE7GVXV3UAC
SLGD73N7IKSOMNUXVKO3DOJIVH3TTURMSAHF6JUEFDP3CINFH6LQC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
7UWLGLA6FAO42YN6IBEFAKMTDUY26IJAQDBHGHHH55OK2SHUIZHAC
FHLFZZ3SG5VGJX25JID6A6C5XLT6Q76RAJDQSYQSZTXQMSIUTCCAC
NTYP3TWGASXUIEJOGZL5XL5CGZVJ6RCAVO3ZFGCCDIAHQ6FE6TKAC
M2JTUQQL2JBWHMN3JG6KO6NDHZ5X7ZW2RF7HVG4WVMS5TE6DYUPQC
TBPJ5WSRM5IKQH7FTAVYTWWUBWW7G2CLT5M6FN7CMPLD6Y77YIWQC
VEVJJKOCDIODY35MQDZFZU7R77IIGIL7HWMEPZ6J5F2BJFGCP4RQC
ZQMQVMFWZIGWBRCB455IKHPTAOUYPLYCSC44NBPPET557RGVRX3AC
A1 = function(id, preserve_screen_top_of_cursor_node)
-- like A, but translate a single node in Nodes to Surface
-- this only works because Nodes is a flat array; we don't support row/col types here yet
print('A1', id)
-- delete previously added shapes for this node:
for i=#Surface,1,-1 do
local x = Surface[i]
if x.id == id then
table.remove(Surface, i)
end
end
-- translate Nodes to Surface
local node = Nodes[id]
compute_layout(node, node.x,node.y, Surface, preserve_screen_top_of_cursor_node)
-- continue the pipeline
B(preserve_screen_top_of_cursor_node)
end
table.insert(nodes_to_render, {type='line', r=0.7,g=0.7,b=0.7, data={node.x+node.w+20,node.y, node.x+node.w+20,node.y+buffer_height}})
table.insert(nodes_to_render, {type='line', r=0.7,g=0.7,b=0.7, data={node.x+node.w+20+4,node.y, node.x+node.w+20+4,node.y+buffer_height}})
table.insert(nodes_to_render, {type='line', r=0.7,g=0.7,b=0.7, data={node.x+node.w+20,node.y, node.x+node.w+20,node.y+buffer_height}, id=node.id})
table.insert(nodes_to_render, {type='line', r=0.7,g=0.7,b=0.7, data={node.x+node.w+20+4,node.y, node.x+node.w+20+4,node.y+buffer_height}, id=node.id})