Commit b2d8780
Fix index-out-of-bounds panic in build_subgraph_layouts when subgraphs have no positioned nodes
SubgraphTree indexes into graph.subgraphs (0..N), but the local
subgraphs vec skips any subgraph whose nodes have no layout positions
yet, causing the two index spaces to diverge.
Fix: build a graph_to_local mapping during the filter pass, size
all_descendants by graph.subgraphs.len() so tree indices are always
valid, and translate through graph_to_local in the bounds-expansion
loop, skipping filtered-out subgraphs.
Regression test added: tests/fixtures/flowchart/subgraph_empty.mmd
reproduces a flowchart with a subgraph that has no positioned nodes.
(cherry picked from commit 1042029)1 parent 97600a0 commit b2d8780
3 files changed
Lines changed: 36 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1321 | 1321 | | |
1322 | 1322 | | |
1323 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
1324 | 1326 | | |
1325 | 1327 | | |
1326 | 1328 | | |
| |||
1337 | 1339 | | |
1338 | 1340 | | |
1339 | 1341 | | |
| 1342 | + | |
1340 | 1343 | | |
1341 | 1344 | | |
1342 | 1345 | | |
| |||
1360 | 1363 | | |
1361 | 1364 | | |
1362 | 1365 | | |
| 1366 | + | |
1363 | 1367 | | |
1364 | 1368 | | |
1365 | 1369 | | |
| |||
1375 | 1379 | | |
1376 | 1380 | | |
1377 | 1381 | | |
1378 | | - | |
1379 | | - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1380 | 1385 | | |
1381 | 1386 | | |
1382 | 1387 | | |
| |||
1400 | 1405 | | |
1401 | 1406 | | |
1402 | 1407 | | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
1403 | 1411 | | |
1404 | 1412 | | |
1405 | 1413 | | |
1406 | 1414 | | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
1407 | 1418 | | |
1408 | 1419 | | |
1409 | 1420 | | |
1410 | 1421 | | |
1411 | 1422 | | |
1412 | 1423 | | |
1413 | | - | |
| 1424 | + | |
1414 | 1425 | | |
1415 | 1426 | | |
1416 | | - | |
| 1427 | + | |
1417 | 1428 | | |
1418 | 1429 | | |
1419 | 1430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
319 | 320 | | |
320 | 321 | | |
321 | 322 | | |
| |||
0 commit comments