fix: left-align DO_TRY sections and shrink container to fit content
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m22s
CI / docker (push) Successful in 42s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 41s

- Left-align all sections (try_body, doFinally, doCatch) within DO_TRY
- Shrink DO_TRY height to match actual content, removing bottom padding

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-28 17:36:01 +01:00
parent 55e1c7cbb5
commit 7c88b03956

View File

@@ -326,6 +326,7 @@ public class ElkDiagramRenderer implements DiagramRenderer {
*/
private void postProcessDoTrySections(LayoutContext ctx) {
for (Map.Entry<String, List<String>> entry : ctx.doTrySectionOrder.entrySet()) {
String doTryId = entry.getKey();
List<String> orderedIds = entry.getValue();
List<ElkNode> sections = new ArrayList<>();
for (String id : orderedIds) {
@@ -334,18 +335,29 @@ public class ElkDiagramRenderer implements DiagramRenderer {
}
if (sections.size() < 2) continue;
// Left-align all sections and stack vertically
double startY = sections.stream().mapToDouble(ElkNode::getY).min().orElse(0);
double spacing = 20;
double currentY = startY;
for (ElkNode section : sections) {
section.setX(COMPOUND_SIDE_PADDING);
section.setY(currentY);
currentY += section.getHeight() + spacing;
}
// Uniform width
double maxWidth = sections.stream().mapToDouble(ElkNode::getWidth).max().orElse(0);
for (ElkNode section : sections) {
section.setWidth(maxWidth);
}
// Shrink DO_TRY parent height to fit its content
ElkNode doTryNode = ctx.elkNodeMap.get(doTryId);
if (doTryNode != null) {
double contentBottom = currentY - spacing + COMPOUND_SIDE_PADDING;
doTryNode.setHeight(contentBottom);
doTryNode.setWidth(maxWidth + 2 * COMPOUND_SIDE_PADDING);
}
}
}