Skip to content

Commit 3153662

Browse files
authored
Merge pull request #1713 from alixander/connections-glob
d2ir: fix glob edge with common glob
2 parents 903313d + 87736b1 commit 3153662

4 files changed

Lines changed: 454 additions & 1 deletion

File tree

ci/release/changelogs/next.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
- Fixes panic when spread substitution referenced a nonexistant var. [#1695](https://github.com/terrastruct/d2/pull/1695)
2626
- Fixes incorrect appendix icon numbering. [#1704](https://github.com/terrastruct/d2/pull/1704)
2727
- Fixes crash when using `--watch` and navigating to an invalid board path [#1693](https://github.com/terrastruct/d2/pull/1693)
28+
- Fixes edge case where nested edge globs were creating excess shapes [#1713](https://github.com/terrastruct/d2/pull/1713)

d2compiler/compile_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,6 +4297,23 @@ x: {
42974297
`, `d2/testdata/d2compiler/TestCompile2/globs/double-glob-override-err-val.d2:6:2: invalid "near" field`)
42984298
},
42994299
},
4300+
{
4301+
name: "creating-node-bug",
4302+
run: func(t *testing.T) {
4303+
g, _ := assertCompile(t, `
4304+
*.*a -> *.*b
4305+
4306+
container_1: {
4307+
a
4308+
}
4309+
4310+
container_2: {
4311+
b
4312+
}
4313+
`, ``)
4314+
assert.Equal(t, 4, len(g.Objects))
4315+
},
4316+
},
43004317
}
43014318

43024319
for _, tc := range tca {

d2ir/d2ir.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func (eid *EdgeID) resolve(m *Map) (_ *EdgeID, _ *Map, common []string, _ error)
435435
}
436436

437437
for len(eid.SrcPath) > 1 && len(eid.DstPath) > 1 {
438-
if !strings.EqualFold(eid.SrcPath[0], eid.DstPath[0]) {
438+
if !strings.EqualFold(eid.SrcPath[0], eid.DstPath[0]) || eid.SrcPath[0] == "*" {
439439
return eid, m, common, nil
440440
}
441441
common = append(common, eid.SrcPath[0])

0 commit comments

Comments
 (0)