File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -66,11 +66,17 @@ private extension LayerTree.Path {
6666 var nodes = [ SubPathNode] ( )
6767
6868 for p in subpaths {
69- let node = SubPathNode ( p)
69+ var node = SubPathNode ( p)
7070 if let idx = nodes. firstIndex ( where: { $0. containsNode ( node) } ) {
7171 nodes [ idx] . append ( node)
7272 } else {
73- nodes. append ( node)
73+ if let idx = nodes. firstIndex ( where: { node. containsNode ( $0) } ) {
74+ // existing node is inside new node
75+ node. append ( nodes [ idx] )
76+ nodes [ idx] = node
77+ } else {
78+ nodes. append ( node)
79+ }
7480 }
7581 }
7682 return nodes
@@ -105,7 +111,14 @@ private struct SubPathNode {
105111 if let idx = children. firstIndex ( where: { $0. containsNode ( node) } ) {
106112 children [ idx] . append ( node)
107113 } else {
108- children. append ( node)
114+ if let idx = children. firstIndex ( where: { node. containsNode ( $0) } ) {
115+ // existing node is inside new node
116+ var node = node
117+ node. append ( children [ idx] )
118+ children [ idx] = node
119+ } else {
120+ children. append ( node)
121+ }
109122 }
110123 }
111124
You can’t perform that action at this time.
0 commit comments