Skip to content

Commit

Permalink
d2ir: fix glob edge with common glob
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Nov 8, 2023
1 parent 7b2e4d6 commit 87736b1
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 1 deletion.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@
- Fixes panic when spread substitution referenced a nonexistant var. [#1695](https://github.com/terrastruct/d2/pull/1695)
- Fixes incorrect appendix icon numbering. [#1704](https://github.com/terrastruct/d2/pull/1704)
- Fixes crash when using `--watch` and navigating to an invalid board path [#1693](https://github.com/terrastruct/d2/pull/1693)
- Fixes edge case where nested edge globs were creating excess shapes [#1713](https://github.com/terrastruct/d2/pull/1713)
17 changes: 17 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4297,6 +4297,23 @@ x: {
`, `d2/testdata/d2compiler/TestCompile2/globs/double-glob-override-err-val.d2:6:2: invalid "near" field`)
},
},
{
name: "creating-node-bug",
run: func(t *testing.T) {
g, _ := assertCompile(t, `
*.*a -> *.*b
container_1: {
a
}
container_2: {
b
}
`, ``)
assert.Equal(t, 4, len(g.Objects))
},
},
}

for _, tc := range tca {
Expand Down
2 changes: 1 addition & 1 deletion d2ir/d2ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func (eid *EdgeID) resolve(m *Map) (_ *EdgeID, _ *Map, common []string, _ error)
}

for len(eid.SrcPath) > 1 && len(eid.DstPath) > 1 {
if !strings.EqualFold(eid.SrcPath[0], eid.DstPath[0]) {
if !strings.EqualFold(eid.SrcPath[0], eid.DstPath[0]) || eid.SrcPath[0] == "*" {
return eid, m, common, nil
}
common = append(common, eid.SrcPath[0])
Expand Down
Loading

0 comments on commit 87736b1

Please sign in to comment.