diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 53295c913..4a542a974 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -42,7 +42,7 @@ func Compile(path string, r io.RuneReader, opts *CompileOptions) (*d2graph.Graph if err != nil { return nil, err } - g = g.SortEdgesByAST() + g.SortEdgesByAST() return g, nil } diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index d46cdeca8..d8a7ca3fb 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1438,7 +1438,7 @@ func (g *Graph) GetBoard(name string) *Graph { return nil } -func (g *Graph) SortEdgesByAST() *Graph { +func (g *Graph) SortEdgesByAST() { edges := append([]*Edge(nil), g.Edges...) sort.Slice(edges, func(i, j int) bool { e1 := edges[i] @@ -1448,7 +1448,5 @@ func (g *Graph) SortEdgesByAST() *Graph { } return e1.References[0].Edge.Range.Before(edges[j].References[0].Edge.Range) }) - g2 := *g - g2.Edges = edges - return &g2 + g.Edges = edges } diff --git a/d2target/class.go b/d2target/class.go index 3a2d2c5e0..f62a3ea43 100644 --- a/d2target/class.go +++ b/d2target/class.go @@ -69,13 +69,3 @@ func (cm ClassMethod) VisibilityToken() string { return "+" } } - -func (c *Class) Copy() *Class { - if c == nil { - return nil - } - return &Class{ - Fields: append([]ClassField(nil), c.Fields...), - Methods: append([]ClassMethod(nil), c.Methods...), - } -} diff --git a/d2target/sqltable.go b/d2target/sqltable.go index 64ee34d58..8332a34c8 100644 --- a/d2target/sqltable.go +++ b/d2target/sqltable.go @@ -50,12 +50,3 @@ func (c SQLColumn) ConstraintAbbr() string { return "" } } - -func (st *SQLTable) Copy() *SQLTable { - if st == nil { - return nil - } - return &SQLTable{ - Columns: append([]SQLColumn(nil), st.Columns...), - } -} diff --git a/e2etests/README.md b/e2etests/README.md index f6f1e8d3c..c25e7ec49 100644 --- a/e2etests/README.md +++ b/e2etests/README.md @@ -17,6 +17,6 @@ If a change results in test diffs, you can run this script to generate a visual report with the old vs new renders. ``` -go run ./e2etests/report/main.go +go run ./e2etests/report/main.go -delta open ./e2etests/out/e2e_report.html ``` diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json index 4d79ffa95..29cf0cdbf 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json @@ -375,6 +375,162 @@ "tooltip": "", "icon": null, "zIndex": 0 + }, + { + "id": "(foo.a -- )[0]", + "src": "foo.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 236 + }, + { + "x": 99, + "y": 496 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foo.b -- )[0]", + "src": "foo.b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 236 + }, + { + "x": 349, + "y": 496 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.c -- )[0]", + "src": "foobar.c", + "srcArrow": "none", + "srcLabel": "", + "dst": "c-lifeline-end-955173837", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 856 + }, + { + "x": 99, + "y": 1116 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.d -- )[0]", + "src": "foobar.d", + "srcArrow": "none", + "srcLabel": "", + "dst": "d-lifeline-end-2106864010", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 856 + }, + { + "x": 349, + "y": 1116 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 } ] } diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg index 622415be4..6fe13d70d 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="648" height="1340" viewBox="-100 -100 648 1340">xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-
JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +JoeDonaldi am top lefti am top righti am bottom lefti am bottom right +