Skip to content

Commit

Permalink
fix d2oracle.set on imported edge
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Feb 9, 2024
1 parent 3129df1 commit 706951b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 37 deletions.
4 changes: 2 additions & 2 deletions d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,14 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
appendMapKey(scope, mk)
return nil
}
// TODO what if the edge is imported, how does this work?
var ok bool
edge, ok = obj.HasEdge(mk)
if !ok {
return errors.New("edge not found")
}
imported = IsImportedEdge(baseAST, edge)
refs := edge.References
if baseAST != g.AST {
if baseAST != g.AST || imported {
refs = getWriteableEdgeRefs(edge, baseAST)
}
onlyInChain := true
Expand Down
4 changes: 2 additions & 2 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2181,10 +2181,10 @@ layers: {
fsTexts: map[string]string{
"yo.d2": `a -> b`,
},
key: `(a -> b).style.stroke`,
key: `(a -> b)[0].style.stroke`,
value: go2.Pointer(`red`),
exp: `...@yo
(a -> b).style.stroke: red
(a -> b)[0].style.stroke: red
`,
},
}
Expand Down
44 changes: 11 additions & 33 deletions testdata/d2oracle/TestSet/import/9.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 706951b

Please sign in to comment.