From 3d45f6ab51f171ea0c0d6eac6713c491110e1a6e Mon Sep 17 00:00:00 2001 From: donglixiaoche Date: Tue, 28 Mar 2023 08:57:15 +0800 Subject: [PATCH] fix: cr, return value --- d2graph/d2graph.go | 7 +++---- d2layouts/d2near/layout.go | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index ebeeb0816..5ffa7954b 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -968,16 +968,15 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R return &dims, nil } -func (obj *Object) IsInsideNearContainer() bool { +func (obj *Object) OuterNearContainer() *Object { temp := obj for temp != nil { - fmt.Println(temp.ID) if temp.Attributes.NearKey != nil { - return true + return temp } temp = temp.Parent } - return false + return nil } type Edge struct { diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index 5b86b892e..b9d3fcbfa 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -225,7 +225,7 @@ func boundingBox(g *d2graph.Graph) (tl, br *geo.Point) { y2 = math.Max(y2, obj.TopLeft.Y+obj.Height) } } else { - if obj.IsInsideNearContainer() { + if obj.OuterNearContainer() != nil { continue } x1 = math.Min(x1, obj.TopLeft.X)