Skip to content

Commit 68a9af9

Browse files
authoredFeb 27, 2024
Merge pull request #1848 from alixander/d2oracle-arrowhead-fill-2
followup fix to #1847
2 parents edc3088 + 9444a63 commit 68a9af9

File tree

4 files changed

+720
-0
lines changed

4 files changed

+720
-0
lines changed
 

‎d2oracle/edit.go

+12
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,14 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
647647
case "source-arrowhead", "target-arrowhead":
648648
var arrowhead *d2graph.Attributes
649649
if reservedKey == "source-arrowhead" {
650+
if edge.SrcArrowhead != nil {
651+
attrs = *edge.SrcArrowhead
652+
}
650653
arrowhead = edge.SrcArrowhead
651654
} else {
655+
if edge.DstArrowhead != nil {
656+
attrs = *edge.DstArrowhead
657+
}
652658
arrowhead = edge.DstArrowhead
653659
}
654660
if arrowhead != nil {
@@ -669,6 +675,12 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
669675
arrowhead.Label.MapKey.SetScalar(mk.Value.ScalarBox())
670676
return nil
671677
}
678+
case "style":
679+
reservedTargetKey = mk.Key.Path[len(mk.Key.Path)-1].Unbox().ScalarString()
680+
if inlined(attrs.Style.Filled) {
681+
attrs.Style.Filled.MapKey.SetScalar(mk.Value.ScalarBox())
682+
return nil
683+
}
672684
}
673685
}
674686
case "style":

‎d2oracle/edit_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,42 @@ a.b -> a.c: {style.animated: true}
15621562
target-arrowhead.shape: diamond
15631563
target-arrowhead.style.filled: true
15641564
}
1565+
`,
1566+
},
1567+
{
1568+
name: "edge-arrowhead-filled/4",
1569+
text: `x -> y: {
1570+
target-arrowhead.shape: diamond
1571+
target-arrowhead.style.filled: true
1572+
}
1573+
`,
1574+
key: `(x -> y)[0].target-arrowhead.style.filled`,
1575+
value: go2.Pointer(`false`),
1576+
1577+
exp: `x -> y: {
1578+
target-arrowhead.shape: diamond
1579+
target-arrowhead.style.filled: false
1580+
}
1581+
`,
1582+
},
1583+
{
1584+
name: "edge-arrowhead-filled/5",
1585+
text: `x -> y: {
1586+
target-arrowhead.shape: diamond
1587+
target-arrowhead.style: {
1588+
filled: false
1589+
}
1590+
}
1591+
`,
1592+
key: `(x -> y)[0].target-arrowhead.style.filled`,
1593+
value: go2.Pointer(`true`),
1594+
1595+
exp: `x -> y: {
1596+
target-arrowhead.shape: diamond
1597+
target-arrowhead.style: {
1598+
filled: true
1599+
}
1600+
}
15651601
`,
15661602
},
15671603
{

‎testdata/d2oracle/TestSet/edge-arrowhead-filled/4.exp.json

+327
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)