Skip to content

Commit 3bdf2d6

Browse files
authored
Merge pull request #444 from hjotha/submit/describer-loop-caption-annotations
fix: emit loop captions during microflow describe
2 parents 5d2962f + 958a16c commit 3bdf2d6

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

mdl/executor/cmd_microflows_show_helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,9 @@ func emitObjectAnnotations(
463463
if split, ok := obj.(*microflows.InheritanceSplit); ok && split.Caption != "" {
464464
*lines = append(*lines, indentStr+fmt.Sprintf("@caption %s", mdlQuote(split.Caption)))
465465
}
466+
if loop, ok := obj.(*microflows.LoopedActivity); ok && loop.Caption != "" {
467+
*lines = append(*lines, indentStr+fmt.Sprintf("@caption %s", mdlQuote(loop.Caption)))
468+
}
466469

467470
// @annotation (attached Annotation objects)
468471
if annotationsByTarget != nil {

mdl/executor/cmd_microflows_show_helpers_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,25 @@ func TestEmitObjectAnnotations_EscapesMultilineText(t *testing.T) {
160160
}
161161
}
162162

163+
func TestEmitObjectAnnotations_LoopCaption(t *testing.T) {
164+
obj := &microflows.LoopedActivity{
165+
BaseMicroflowObject: microflows.BaseMicroflowObject{
166+
BaseElement: model.BaseElement{ID: mkID("loop")},
167+
Position: model.Point{X: 100, Y: 200},
168+
},
169+
Caption: "Loop owner's\ncaption",
170+
}
171+
172+
var lines []string
173+
// Pass nil flow maps — @anchor emission is intentionally suppressed here.
174+
emitObjectAnnotations(obj, &lines, "", nil, nil, nil, nil)
175+
176+
got := strings.Join(lines, "\n")
177+
if !strings.Contains(got, "@caption 'Loop owner''s\\ncaption'") {
178+
t.Fatalf("expected escaped loop caption, got:\n%s", got)
179+
}
180+
}
181+
163182
func TestPrependFreeAnnotationLines_ModelAnnotationsStayFree(t *testing.T) {
164183
oc := &microflows.MicroflowObjectCollection{
165184
Objects: []microflows.MicroflowObject{

0 commit comments

Comments
 (0)