This commit is contained in:
Alexander Wang 2024-07-27 10:04:15 -06:00
parent 32ece4a642
commit e0d3938245
No known key found for this signature in database
GPG key ID: BE3937D0D52D8927
2 changed files with 12 additions and 13 deletions

View file

@ -19,3 +19,4 @@
- Fix importing a file with nested boards [#1998](https://github.com/terrastruct/d2/pull/1998) - Fix importing a file with nested boards [#1998](https://github.com/terrastruct/d2/pull/1998)
- Fix importing a file with underscores in links [#1999](https://github.com/terrastruct/d2/pull/1999) - Fix importing a file with underscores in links [#1999](https://github.com/terrastruct/d2/pull/1999)
- Replace a panic with an error message resulting from invalid `link` usage [#2011](https://github.com/terrastruct/d2/pull/2011) - Replace a panic with an error message resulting from invalid `link` usage [#2011](https://github.com/terrastruct/d2/pull/2011)
- Fix globs not applying to scenarios on keys that were applied in earlier scenarios [#2021](https://github.com/terrastruct/d2/pull/2021)

View file

@ -24,17 +24,6 @@ type globContext struct {
appliedEdges map[string]struct{} appliedEdges map[string]struct{}
} }
func (g *globContext) copyApplied(from *globContext) {
g.appliedFields = make(map[string]struct{})
for k, v := range from.appliedFields {
g.appliedFields[k] = v
}
g.appliedEdges = make(map[string]struct{})
for k, v := range from.appliedEdges {
g.appliedEdges[k] = v
}
}
type compiler struct { type compiler struct {
err *d2parser.ParseError err *d2parser.ParseError
@ -390,13 +379,22 @@ func (c *compiler) overlay(base *Map, f *Field) {
func (g *globContext) copy() *globContext { func (g *globContext) copy() *globContext {
g2 := *g g2 := *g
g2.refctx = g.root.refctx.Copy() g2.refctx = g.root.refctx.Copy()
return &g2 return &g2
} }
func (g *globContext) copyApplied(from *globContext) {
g.appliedFields = make(map[string]struct{})
for k, v := range from.appliedFields {
g.appliedFields[k] = v
}
g.appliedEdges = make(map[string]struct{})
for k, v := range from.appliedEdges {
g.appliedEdges[k] = v
}
}
func (g *globContext) prefixed(dst *Map) *globContext { func (g *globContext) prefixed(dst *Map) *globContext {
g2 := g.copy() g2 := g.copy()
prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst)) prefix := d2ast.MakeKeyPath(RelIDA(g2.refctx.ScopeMap, dst))
g2.refctx.Key = g2.refctx.Key.Copy() g2.refctx.Key = g2.refctx.Key.Copy()
if g2.refctx.Key.Key != nil { if g2.refctx.Key.Key != nil {