Skip to content

Commit

Permalink
globs: fix imported case
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Dec 5, 2023
1 parent 3edfaa4 commit 2c928c5
Show file tree
Hide file tree
Showing 3 changed files with 465 additions and 2 deletions.
5 changes: 3 additions & 2 deletions d2ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ func (c *compiler) ampersandFilterMap(dst *Map, ast, scopeAST *d2ast.Map) bool {
func (c *compiler) compileMap(dst *Map, ast, scopeAST *d2ast.Map) {
var globs []*globContext
if len(c.globContextStack) > 0 {
previousGlobs := c.globContextStack[len(c.globContextStack)-1]
if NodeBoardKind(dst) == BoardLayer {
previousGlobs := c.globContexts()
// A non-root layer implies it's an import, in which case the previous globs should be inherited (the else block)
if NodeBoardKind(dst) == BoardLayer && !dst.Root() {
for _, g := range previousGlobs {
if g.refctx.Key.HasTripleGlob() {
globs = append(globs, g.prefixed(dst))
Expand Down
15 changes: 15 additions & 0 deletions d2ir/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ label: meow`,
assertQuery(t, m, 0, 0, 1, "hi")
},
},
{
name: "pattern-value",
run: func(t testing.TB) {
_, err := compileFS(t, "index.d2", map[string]string{
"index.d2": `userWebsite
userMobile
user*: @x
`,
"x.d2": `shape: person
label: meow`,
})
assert.Success(t, err)
},
},
}

runa(t, tca)
Expand Down
Loading

0 comments on commit 2c928c5

Please sign in to comment.