Skip to content

Commit

Permalink
Merge pull request #2244 from alixander/d2oracle-step-bug
Browse files Browse the repository at this point in the history
d2oracle: exclude edges from writeable object refs
  • Loading branch information
alixander authored Dec 12, 2024
2 parents d9f6320 + a68ab3b commit 73cfa6c
Show file tree
Hide file tree
Showing 3 changed files with 698 additions and 1 deletion.
25 changes: 25 additions & 0 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2666,6 +2666,31 @@ scenarios: {
}
}
}
`,
},
{
name: "step-connection",

text: `steps: {
1: {
Modules -- Metricbeat: {
style.stroke-width: 1
}
}
}
`,
key: `Metricbeat.style.stroke`,
value: go2.Pointer(`red`),
boardPath: []string{"1"},
exp: `steps: {
1: {
Modules -- Metricbeat: {
style.stroke-width: 1
}
Metricbeat.style.stroke: red
}
}
`,
},
}
Expand Down
2 changes: 1 addition & 1 deletion d2oracle/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func GetID(key string) string {

func GetWriteableRefs(obj *d2graph.Object, writeableAST *d2ast.Map) (out []d2graph.Reference) {
for i, ref := range obj.References {
if ref.ScopeAST == writeableAST && ref.Key.Range.Path == writeableAST.Range.Path {
if ref.ScopeAST == writeableAST && ref.Key.Range.Path == writeableAST.Range.Path && len(ref.MapKey.Edges) == 0 {
out = append(out, obj.References[i])
}
}
Expand Down
Loading

0 comments on commit 73cfa6c

Please sign in to comment.