Commit 6a19dec
Layered edge labels: grow canvas + fit self-loop captions; harden linter + tests
Address PR #6 review feedback (re-verified against d0bac93):
- DiagramLayout.swift: the state/class/ER (layered) router finalized its
canvas size before placeRunLabels, so a caption on the rightmost/bottom-most
run — or one nudged perpendicular off it — could extend past the scene and
trip the off-canvas rule. Grow the canvas around the placed label anchors,
the same post-placement expansion layoutFlat already does. (chatgpt-codex
P2 / coderabbit Major)
- DiagramLayout.swift: a labeled self-loop routed a fixed 24pt loop regardless
of caption length, cramming the word onto too short a run (label-crowds-edge,
e.g. `A --> A: retry`). Grow the loop's vertical return run to the label
height plus a stub on each side; keep the top/bottom bars short so a wide
loop never gores a neighbouring box (the er fixture's NODE/EDGE pair).
- DiagramScene.swift: validate anchorEdge against edges.indices, not just
`< count`, so a negative anchor can't trap on the subscript. (coderabbit
Major, stability)
- EdgeLabelLayoutTests.swift: fail (XCTUnwrap) when a labeled edge has no
anchor instead of silently skipping, assert the full flowchartLabelStub (14)
rather than a hard-coded 10, and add a layered self-loop lint-clean
regression. (coderabbit Minor)
Declined the flowchart placeRunLabels "hard-reject runs / drop perpendicular
nudges / reserve geometry" rewrite: median-dummy widening already reserves
label space, the label-on-fixture/label-crowds-edge linter rules enforce the
contract over 30 lint-clean fixtures, and the one real geometry gap (self-loop
captions) is fixed above. A wholesale rewrite risks regressing the just-landed
placement work with no demonstrated defect.
swift build + full swift test green (198 tests, 2 skipped); 30 fixtures
lint-clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoLDcosyaHg3tAKhU5SQaw1 parent d0bac93 commit 6a19dec
3 files changed
Lines changed: 45 additions & 8 deletions
File tree
- Sources/MermaidLayout
- Tests/MermaidLayoutTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
940 | 940 | | |
941 | 941 | | |
942 | 942 | | |
943 | | - | |
| 943 | + | |
944 | 944 | | |
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
950 | 954 | | |
951 | 955 | | |
952 | 956 | | |
953 | | - | |
954 | | - | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
955 | 961 | | |
956 | 962 | | |
957 | 963 | | |
| |||
1065 | 1071 | | |
1066 | 1072 | | |
1067 | 1073 | | |
1068 | | - | |
| 1074 | + | |
1069 | 1075 | | |
1070 | 1076 | | |
1071 | 1077 | | |
| |||
1077 | 1083 | | |
1078 | 1084 | | |
1079 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
1080 | 1095 | | |
1081 | 1096 | | |
1082 | 1097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
| |||
0 commit comments