use helpers

This commit is contained in:
Alexander Wang 2023-04-06 21:02:12 -07:00
parent a2cffc9341
commit 754e0ece80
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE

View file

@ -88,13 +88,13 @@ func (c *compiler) compileField(dst *Map, kp *d2ast.KeyPath, refctx *RefContext)
} }
switch NodeBoardKind(f) { switch NodeBoardKind(f) {
case BoardScenario: case BoardScenario:
c.overlay(dst.Parent().Parent().(*Map), f) c.overlay(ParentBoard(f).Map(), f)
case BoardStep: case BoardStep:
stepsMap := dst.Parent().Map() stepsMap := ParentMap(f)
for i := range stepsMap.Fields { for i := range stepsMap.Fields {
if stepsMap.Fields[i] == f { if stepsMap.Fields[i] == f {
if i == 0 { if i == 0 {
c.overlay(dst.Parent().Parent().(*Map), f) c.overlay(ParentBoard(f).Map(), f)
} else { } else {
c.overlay(stepsMap.Fields[i-1].Map(), f) c.overlay(stepsMap.Fields[i-1].Map(), f)
} }