Skip to content

Commit edc3088

Browse files
authored
Merge pull request #1847 from alixander/d2oracle-arrowhead-fill
d2oracle: fix set arrowhead fill
2 parents 5117d2b + c8fcd11 commit edc3088

File tree

5 files changed

+1000
-2
lines changed

5 files changed

+1000
-2
lines changed

d2oracle/edit.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
653653
}
654654
if arrowhead != nil {
655655
if reservedTargetKey == "" {
656-
if len(mk.Key.Path[reservedIndex:]) != 2 {
657-
return errors.New("malformed style setting, expected 2 part path")
656+
if len(mk.Key.Path[reservedIndex:]) < 2 {
657+
return errors.New("malformed style setting, expected >= 2 part path")
658658
}
659659
reservedTargetKey = mk.Key.Path[reservedIndex+1].Unbox().ScalarString()
660660
}

d2oracle/edit_test.go

+44
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,50 @@ a.b -> a.c: {style.animated: true}
15181518
value: go2.Pointer(`diamond`),
15191519

15201520
exp: `x -> y: {target-arrowhead.shape: diamond}
1521+
`,
1522+
},
1523+
{
1524+
name: "edge-arrowhead-filled/1",
1525+
text: `x -> y
1526+
`,
1527+
key: `(x -> y)[0].target-arrowhead.style.filled`,
1528+
value: go2.Pointer(`true`),
1529+
1530+
exp: `x -> y: {target-arrowhead.style.filled: true}
1531+
`,
1532+
},
1533+
{
1534+
name: "edge-arrowhead-filled/2",
1535+
text: `x -> y: {
1536+
target-arrowhead: * {
1537+
shape: diamond
1538+
}
1539+
}
1540+
`,
1541+
key: `(x -> y)[0].target-arrowhead.style.filled`,
1542+
value: go2.Pointer(`true`),
1543+
1544+
exp: `x -> y: {
1545+
target-arrowhead: * {
1546+
shape: diamond
1547+
style.filled: true
1548+
}
1549+
}
1550+
`,
1551+
},
1552+
{
1553+
name: "edge-arrowhead-filled/3",
1554+
text: `x -> y: {
1555+
target-arrowhead.shape: diamond
1556+
}
1557+
`,
1558+
key: `(x -> y)[0].target-arrowhead.style.filled`,
1559+
value: go2.Pointer(`true`),
1560+
1561+
exp: `x -> y: {
1562+
target-arrowhead.shape: diamond
1563+
target-arrowhead.style.filled: true
1564+
}
15211565
`,
15221566
},
15231567
{

testdata/d2oracle/TestSet/edge-arrowhead-filled/1.exp.json

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

0 commit comments

Comments
 (0)